Re: binding free symbols in a lambda definition

2017-02-07 Thread Lindsay John Lawrence
'fill' (http://software-lab.de/doc/refF.html#fill) does the job in some cases as well and is a bit easier to read... : (de adder (N) (let @X N (fill '((x) (+ x @X) -> adder : (adder 1) -> ((x) (+ x 1)) : (adder 2) -> ((x) (+ x 2)) : ((adder 1) 99) -> 100 /Lindsay

Re: binding free symbols in a lambda definition

2017-02-07 Thread Lindsay John Lawrence
You can also do this... : (de adder (N) (list '(x) (list '+ 'x (eval 'N -> adder : (adder 1) -> ((x) (+ x 1)) : (adder 2) -> ((x) (+ x 2)) : ((adder 99) 1) -> 100 Small examples like this one are great learning devices :) As Erik pointed out though, 'curry' is probably more general purpose

Re: binding free symbols in a lambda definition

2017-02-07 Thread Lindsay John Lawrence
This works: :(de myf (F L) (F L)) -> myf : (let (L 99) (myf '((x) (+ (car x) `L)) (1 2))) -> 100 The key there is the back-quote (`) before the L to force evaluation See the doc section on 'Read-Macros' http://software-lab.de/doc/ref.html#macro-io /Lindsay On Tue, Feb 7, 2017 at 7:55 PM, pd

Re: binding free symbols in a lambda definition

2017-02-07 Thread Erik Gustafson
I think 'curry' is what you're looking for. Your 'adder' example could be written as: : (de adder (@N) (curry (@N) (X) (+ X @N))) -> adder : (adder 3) -> ((X) (+ X 3)) : (doc 'curry) # for more info :) Hope that helps, Erik On Feb 7, 2017 10:04 PM, "pd"

Re: A script that concatenates ref. and tutorial files into one file

2017-02-07 Thread Alexander Burger
Hi Jon, > I have noticed that frequent use of ‘setq’ has been questioned recently on > this list. In my convConcat.l script there are quite a few setq’s that > possibly > could have been coded in a better way. Let me know if you spot some obvious > candidates. Basically there is nothing bad

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

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

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: > >

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

A script that concatenates ref. and tutorial files into one file

2017-02-07 Thread Jon Kleiser
Hi, As a few has asked for a monolithic reference (and tutorial) HTML file, I got tempted to try to write a PicoLisp program that does such a concatenation. The difficult part, of course, was adjusting all the internal links, and it was a bit more challenging than I first thought, especially

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