bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Recursive Lambda


From: Christian Robert
Subject: Re: [Bug-apl] Recursive Lambda
Date: Tue, 5 Jul 2016 04:12:01 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1

If no one noticed, it is a way to do (if;then;else) in a Lambda. (if;then;else) 
everywhere in fact.

Xtian.

On 2016-07-05 01:43, Christian Robert wrote:
I was under the impression that recursive controlled Lambda was near impossible 
to write.

here an example for factorial:


      fact←{⍎↑(⍵>2)↓⌽ '⍵ × fact ⍵-1' '1⌈⍵'}

      fact 10
3628800
      fact 2
2
      fact 1
1
      fact 0
1
      fact 14
87178291200
      !14
87178291200


This IDIOM, from the 80's, can do that. What is in (...) is the condition and 
it will execute
the first statement if true, else the second one.

for your eyes,

Xtian.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]