Jump to content

Combine data in list


Scoutr4

Recommended Posts

i want to edit the list like this :

Example :
List ; ( 1 2 3 4 5 6 7 8 9)

how do i make the new list?

New List ; ((1 2 3) (4 5 6) (7 8 9))

 

Edited by Scoutr4
Link to comment
Share on other sites

  • Scoutr4 changed the title to Combine data in list

Possible way

(defun l-to-3 (lst / )
  (if lst
    (cons
      (list
        (car lst)
        (cadr lst)
        (caddr lst)
      )
      (l-to-3 (cdddr lst))
    )
  )
)
(mapcar '(lambda (x) (vl-remove nil x)) (l-to-3 (list 1 2 3 4 5 6 7 8 9 10)))

 

  • Like 1
Link to comment
Share on other sites

There is a lot of list manipulation examples in the Challenges section of the swamp similar to what you were looking for worth having a look.

image.png.cc998897b9b9dfec823963759727542f.png

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...