Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread Alexander Burger
On Tue, Feb 07, 2017 at 06:44:43AM -0800, Lindsay John Lawrence wrote: >((= '() Lst) '() ) > .. > However when I (pp 'selectN) it wrote the line where I am trying to test >((= 'NIL Lst) 'NIL) Yes, the reader returs the symbol NIL when it sees () > Is that correct? Shouldn't the pp outp

Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread Lindsay John Lawrence
I just noticed... my original source for the selectN function is this... (de selectN (Lst P) .. ((= '() Lst) '() ) .. However when I (pp 'selectN) it wrote the line where I am trying to test for an empty list as (de selectN (Lst P) .. ((= 'NIL Lst) 'NIL) .. Is that correct? Shouldn't the

Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread Lindsay John Lawrence
Thanks! I still trip over those nuances if I don't pay attention testing for NIL or '(), or not, in lists and symbols. /Lindsay On Mon, Feb 6, 2017 at 11:13 PM, Alexander Burger wrote: > On Tue, Feb 07, 2017 at 07:41:45AM +0100, Alexander Burger wrote: > > (cond > >

Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread Lindsay John Lawrence
Thanks Alex! recur/recurse... I hadn't noticed those functions in the picolisp function library until now. Very useful. /Lindsay On Mon, Feb 6, 2017 at 10:41 PM, Alexander Burger wrote: > Hi Lindsay, > > > I couldn't resist tinkering with this a bit more. > > Many thanks for this and all the

Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread Alexander Burger
Hi Jon, > I wasn’t aware of nor, nand, nond. Maybe there should have been a few more > “See also” in the docs. True! I've added some ... ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread dean
Wow...really pleased I asked. Those are great examples and I'm sure I'll learn a lot from them. I've needed to process lists/trees most of programming "life" and the languages I've used haven't exactly regarded them as first class citizens and this has slowed me down quite a lot. I don't have that

Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread Jon Kleiser
Hi, I wasn’t aware of nor, nand, nond. Maybe there should have been a few more “See also” in the docs. /Jon > On 7. Feb, 2017, at 08:31, Alexander Burger wrote: > > On Tue, Feb 07, 2017 at 08:13:06AM +0100, Alexander Burger wrote: >> Better to use (not Lst). > > One more note: I even try to

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Alexander Burger
On Tue, Feb 07, 2017 at 08:13:06AM +0100, Alexander Burger wrote: > Better to use (not Lst). One more note: I even try to avoid 'not' whenever possible, as it is an additional function call overhead. It is often possible to use the complementary flow function, like (ifn Lst ..) instead of (if (no

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Alexander Burger
On Tue, Feb 07, 2017 at 07:41:45AM +0100, Alexander Burger wrote: > (cond >((= 'NIL Lst) 'NIL) One important note: (= 'NIL Lst) is not a good idea. Better to use (not Lst). (= NIL Lst) would compare *names* if 'Lst' happened to be a symbol, so (= NIL "NIL") returns T.

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Alexander Burger
Hi Lindsay, > I couldn't resist tinkering with this a bit more. Many thanks for this and all the previous examples! > # -- > (de selectN (Lst P) >(let selectNN > '((Lst P I) > (cond > ((= 'NIL Lst) 'NIL) >

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Lindsay John Lawrence
I couldn't resist tinkering with this a bit more. # -- (de selectN (Lst P) (let selectNN '((Lst P I) (cond ((= 'NIL Lst) 'NIL) ((P (car Lst) I) (cons (car Lst)

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Lindsay John Lawrence
Once I started to get the hang of the basic building blocks, I started seeing patterns and ways to build on what I had written before e.g. To me, the next logical development of dropN, pickN is to allow providing a predicate function... effectively making it a general purpose list filter #

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Lindsay John Lawrence
All of those problems are fun to explore... try writing different versions of the selected solutions, iterative vs recursive, using just basic list building block functions vs the wonderfully convenient functions that picolisp provides, etc This particular one piqued my interest enough to try writ

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
I just came back to say I just looked and didn't realise I had to click P16 to see that function Thanks once again. Just goes to show...however idiot-proof you make your system someone will just invent a better idiot :) On 6 February 2017 at 22:51, dean wrote: > Oh gosh...I missed that c

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
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 < lawrence.lindsayj...@gmail.com> wrote: > P16 (**) Drop every

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Lindsay John Lawrence
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

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
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

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Alexander Burger
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 (fi

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread Alexander Burger
Hi Dean, > 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 ...) > I found drop (in ninety nine...

replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
Hi I'd like to split a list '(txt1 2 txt2 6 into 2 lists '(txt1 txt2... and '(2 6 I found drop (in ninety nine...) which looks ideal but it's apparently undefined in pil64. I've looked for something similar but it's not jumping out :) Any help much appreciated.