• Profile picture of Karim
  • Profile picture of Jean


Groupe Public active 20 hours et 30 minutes ago

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

Separate integers or letters

Auteur 2 Utilisateurs souscrits |
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!

Août 10, 2018 à 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)


Août 10, 2018 à 15:08 #27426

Vous devez être connecté pour répondre à ce sujet.

Log in now