sieves

15 views
Skip to first unread message

Ole Schmidt

unread,
Dec 30, 2012, 5:05:33 PM12/30/12
to symbolic...@googlegroups.com
Hi,

I have a list: (a b c d e f g h i j k l )
or: (1 2 3 4 5 6 7 8 9 10 11 12)

how can get something for example every third (or n-th) element of my list, like:
(a c f i and so forth...
or: (1 3 6 9...

with length values it must be: (1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8)
into: (1/8 -1/8 -1/8 1/8 -1/8 -1/8 1/8 ....

in real life it should be a list of unsorted symbols and length values
a sort xenaxis sieve for already existing material.
Also the ability of mixing the sieves (I think remember that the lisp functions union do not preserve the positions of the elements of the list)

thanks for any hints

ole

stephane boussuge

unread,
Dec 31, 2012, 8:34:50 AM12/31/12
to symbolic...@googlegroups.com
Hi Ole,

this function can help:


(defun collect-every-n (lst strt n)
"collecte dans une liste de symbole lst chaque symbole tout les n en commençant a l'index strt"
  (loop for i from strt to (- (length lst) 1) by n      
        collect (nth i lst)))

;;usage:
;;(collect-every-n '(a b c d e f g h) 0 3)
;;--> (a d g)




cheers


stf

--
You received this message because you are subscribed to the Google Groups "Symbolic Composer" group.
To post to this group, send email to symbolic...@googlegroups.com.
To unsubscribe from this group, send email to symboliccompos...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/symboliccomposer?hl=en.



ole

unread,
Dec 31, 2012, 8:25:15 AM12/31/12
to symbolic...@googlegroups.com
that's half way there, thanks!


ole
Reply all
Reply to author
Forward
0 new messages