Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:09:54+00:00 2026-06-17T05:09:54+00:00

Trying to learn lisp, want to delete every nth. I only managed to delete

  • 0

Trying to learn lisp, want to delete every nth. I only managed to delete the first (nth) element

(defun delete-nth (n list)
(if (zerop n)
(cdr list)
(let ((cons (nthcdr (1- n) list)))
  (if cons
    (setf (cdr cons) (cddr cons))
    cons))))

I’d like to delete the next nth and so on

Also I tried this:

(defun remove-nth (list n)
(remove-if (constantly t) list :start n :end (+ 1 n)))

No idea how to start again

What I was thinking was concatenating, but I have no idea of how to keep track of my position.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:09:55+00:00Added an answer on June 17, 2026 at 5:09 am

    An alternative way to do the same thing:

    (defun remove-all-nth (list period)
       (remove-if
        (let ((iterator 0))
          (lambda (x)
            (declare (ignore x))
            (= 0 (mod (incf iterator) period)))) list))
    (remove-all-nth '(1 2 3 4 5 6 7 8 9 0) 3)
    ; (1 2 4 5 7 8 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn lisp and as i'm making my first steps i got
I'm trying to learn Common Lisp and want to use regular expressions for parsing
Trying to learn C. Want to read the first line of a text file,
I'm trying to learn Lisp (elisp, actually), and I tried writing the following function
I'm trying to learn common lisp currently and I've been using sbcl (I hope
I'm trying the project euler problems to learn common lisp and I'm stuck pretty
I am familiar with Common Lisp and trying to learn some Scheme, so I
I'm trying to learn LISP and was going through a code example where something
I'm an experienced C++/.NET/Java Windows/web programmer trying to learn (Common) Lisp. I'm reading Practical
I'm trying to learn Lisp but I got stuck by this example (you can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.