hi all,
I totally dont like it. I vote.
All this useless.
Can you write here #Usage examples of (if-let) in current language feature
set?
Coder already have all needed, like in forth.
If coder want, it have all required to implement this by himself.
Like reduce and -> from clojure I've used to emulate for 4clojure tasks.
(de reduce ("Fun" "Lst")
(let "A" (car "Lst")
(for "N" (cdr "Lst")
(setq "A" ("Fun" "A" "N")) )
"A" ) )
(de -> ("X" . "A")
(for "Form" "A"
(setq "X" (apply (car "Form") (cdr "Form") "X")) ) )
Code is ok, but useless inside pl feature set.
p.s. Create wiki page and collect code as useful snippets.
On Mon, Aug 10, 2015 at 5:10 AM, Rick Hanson wrote:
> I like the idea of `if-let` (which you can see in Clojure[1], and
> probably other languages). It's like anaphoric `if`[2] but better
> because you can name the result of the conditional test. (Intentional
> variable capture is always best when you are controlling the variable
> names; not having a name forced upon you.)
>
> I think this is the idea Alex had for `let?`[3]; however it seems
> `let?` doesn't work with pil64 pattern bindings (i.e. destructuring
> binds) and `let?` doesn't seem to have the possibility of an else
> clause (either that or my imagination and overall pil knowledge
> suffers enough not to see such a possibility -- Alex will tell me :).
>
> Anyway, please feel comment, criticize, etc. If you do, I will learn
> something. Thanks! --Rick
>
> # Usages
> (if-let X 13 (- X 1) 0) #-> 12
> (if-let X 13 (- X 1)) #-> 12 # you can leave off the Else clause.
> (if-let X '() (- X 1))#-> NIL # b/c no Else clause and false condition.
> (if-let X 0 (+ 42 X) -1) #-> 42 # because 0 is "truthy".
> (if-let (X Y) (1 2) Y 42) #-> 2 # pattern binding for pil64.
> (if-let (X Y) 1 Y 42) #-> NIL # because the pattern binding failed.
> (if-let (X Y) '() Y "test failed") #-> "test failed"
> (if-let (X Y) NIL Y "test failed") #-> "test failed"
>
> # A definition
> (de if-let "Args"
> ## Better than anaphoric `if` because you can name the test result
> ## yourself.
> (let ((@Pattern "Test" @Then @Else) "Args"
> @Test-Result (eval "Test"))
> (eval
> (fill
> '(if @Test-Result
>(let (@Pattern @Test-Result)
> @Then)
>@Else)
> '(@Pattern @Test-Result @Then @Else)
>
>
> [1] http://clojuredocs.org/clojure.core/if-let
> [2] http://www.bookshelf.jp/texi/onlisp/onlisp_15.html#SEC100
> [3] http://software-lab.de/doc/refL.html#let?
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>