Group Admins

  • Profile picture of Karim
  • Profile picture of Jean


Public Group active 1 day, 5 hours ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Separate integers or letters

Author 2 Subscribed Users |
Profile photo of Jimmie


I would like to know if there’s a lisp native function that would separate individual integers or letters respectively from numbers or words. For instance, if I have the word ‘word’, I want to obtain a list of individual letters such as in ‘(w o r d)’ ; same thing with numbers such as in: ‘156’ => ‘(1 5 6)’.

Many thanks for any help!

August 10, 2018 at 13:59 #27424
Profile photo of Jean

I think you can just use MAP:

(map 'list 'identity "abcd") => (#\a #\b #\c #\d)
(map 'list 'string "abcd") => ("a" "b" "c" "d")

for a number you will first need to convert the number into a string:
(map 'list #'(lambda (x) (read-from-string (string x))) (write-to-string 1234)) => (1 2 3 4)


August 10, 2018 at 15:08 #27426

You must be logged in to reply to this topic.

Log in now