Oh gosh...I missed that completely...Thanks Lindsay...That explains everything! I'm really pleased you told me that because drop looks like a really useful function. Best Regards Dean
On 6 February 2017 at 22:27, Lindsay John Lawrence < [email protected]> wrote: > P16 (**) Drop every N’th element from a list. > > (de drop (Lst N) > (make > (for (I . X) Lst > (unless (=0 (% I N)) > (link X) ) ) ) ) > > : (drop ’(a b c d e f g h i k) 3) > -> (a b d e g h k) > > 'drop' is the function given as a solution to the problem. > > /Lindsay > > > On Mon, Feb 6, 2017 at 1:24 PM, dean <[email protected]> wrote: > >> Hi Alex >> : (filter prog2 (1 a 2 b 3 c) '(T NIL .)) >> -> (1 2 3) >> : (filter prog2 (1 a 2 b 3 c) '(NIL T .)) >> -> (a b c) >> >> Yes the above is exactly what I'm after. >> >> I copied this drop example straight from ninety nine.. >> ? P16 (**) Drop every N'th element from a list. >> : (drop '(a b c d e f g h i k) 3) >> !? (drop '(a b c d e f g h i k) 3) >> drop -- Undefined >> >> I'm not sure why I'm getting "undefined". >> I'm using the pil in my picolisp directory.... which looks like this.... >> exec ${0%/*}/bin/picolisp ${0%/*}/lib.l @ext.l "$@" >> i.e. not the one in /bin which contains /usr,,,, which I think ISN'T >> local and I think I compiled a local version. >> >> Irrespective....thank you very much for your solution. >> >> Best Regards Dean >> >> >> On 6 February 2017 at 15:24, Alexander Burger <[email protected]> >> wrote: >> >>> On Mon, Feb 06, 2017 at 12:25:14PM +0100, Alexander Burger wrote: >>> > > I'd like to split a list '(txt1 2 txt2 6.... >>> > > into 2 lists >>> > > '(txt1 txt2... >>> > > and >>> > > '(2 6 >>> > >>> > You could for example filter them: >>> > >>> > (let >>> > (Lst '(txt1 2 txt2 6) >>> > A (filter sym? Lst) >>> > B (filter num? Lst) ) >>> > ... use A and B ...) >>> >>> It is not clear what you need. >>> >>> >>> If, for example, you want every *second* element, there is a nice trick: >>> >>> : (filter prog2 (1 a 2 b 3 c) '(T NIL .)) >>> -> (1 2 3) >>> >>> : (filter prog2 (1 a 2 b 3 c) '(NIL T .)) >>> -> (a b c) >>> >>> Similarly, you can extract other sequences if you pass the right pattern >>> of >>> NIL's and T's. >>> >>> ♪♫ Alex >>> -- >>> UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe >>> >> >> >
