Hi Wilhelm,

> Hello, I've recently stumbled across Picolisp
> (while playing around with Termux) and have

Welcome o/ :)

> experimented with making a function to
> generate incrementor functions, e.g. (make-inc
> 2) would return a function that adds two to
> its input. My current solution looks like
> this:
> 
> : (de make-inc (X) (list '(Y) (list '+ X 'Y)))
> ...

This is fine.


> : (setq inc1 (make-inc 1))
> -> ((Y) (+ 1 Y))
> : (setq inc2 (make-inc 2))
> -> ((Y) (+ 2 Y))
> : (inc1 3)
> -> 4
> : (inc2 3)
> -> 5
> 
> ..but I am wondering if there might be more
> idiomatic approaches that allow the "function
> under construction" to be specified in a more
> readable fashion than building it up using
> "list"? Is there perhaps a mechanism for
> temporarily escaping from a quoted section to
> evaluate a specific symbol? Or some other
> approach that is similar where the "templated"
> parts of the function being built can be
> written as they would normally appear?

You could use 'curry' (https://software-lab.de/doc/refC.html#curry)

   : (de make-inc (@X)
      (curry (@X)
         (Y) (+ @X Y) ) )
   -> make-inc
   : (make-inc 2)
   -> ((Y) (+ 2 Y))

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to