Palindromic Expression for Phi: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "Some find that APL expressions can have a poetic beauty. Phil Last submitted the following variable-free recursive dfn to compute the limit of a converging function, equiv...")
 
m (Text replacement - "<source" to "<syntaxhighlight")
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Some find that APL expressions can have a poetic beauty. Phil Last submitted the following variable-free recursive [[dfn]] to compute the limit of a converging function, equivalent to the derived monadic operator <source lang=apl inline>⍣≡</source>:<ref>Dyalog. [https://dfns.dyalog.com/n_limit.htm Function power limit (fixpoint)]. [[Dfns workspace]]. 2019-02-07.</ref>
Some find that APL expressions can have a poetic beauty. Phil Last submitted the following variable-free recursive [[dfn]] to compute the limit of a converging function, equivalent to the derived monadic operator <syntaxhighlight lang=apl inline>⍣≡</syntaxhighlight>:<ref>Dyalog. [https://dfns.dyalog.com/n_limit.htm Function power limit (fixpoint)]. [[Dfns workspace]]. 2019-02-07.</ref>
<source lang=apl>
<syntaxhighlight lang=apl>
limit←{            ⍝ Function power limit (fixpoint).
limit←{            ⍝ Function power limit (fixpoint).
     ⍵ ⍺⍺{          ⍝ 'old' value:
     ⍵ ⍺⍺{          ⍝ 'old' value:
Line 7: Line 7:
     }⍺⍺ ⍵          ⍝ 'new' value.
     }⍺⍺ ⍵          ⍝ 'new' value.
}
}
</source>
</syntaxhighlight>
[[John Scholes]] noted that it was close to being a [[wikipedia:palindrome|palindrome]], so he inlined it and he amended it with dummy code to make its invocation for finding the [[wikipedia:golden ratio|golden ratio]] even closer to palindromic:
[[John Scholes]] noted that it was close to being a [[wikipedia:palindrome|palindrome]], so he inlined it and he amended it with dummy code to make its invocation for finding the [[wikipedia:golden ratio|golden ratio]] even closer to palindromic:
<source lang=apl>
<syntaxhighlight lang=apl>
       1{1+÷⍵}{⍵ ⍺⍺{⍺≡⍵:⍵ ⋄ ⍵ ⍺⍺ ∇∇ ⍺⍺ ⍵ ⋄ ⍵:⍵≡⍺}⍺⍺ ⍵}{⍵÷+1}1
       1{1+÷⍵}{⍵ ⍺⍺{⍺≡⍵:⍵ ⋄ ⍵ ⍺⍺ ∇∇ ⍺⍺ ⍵ ⋄ ⍵:⍵≡⍺}⍺⍺ ⍵}{⍵÷+1}1
1.618033989
1.618033989
</source>
</syntaxhighlight>
Scholes then published a minute-long video with musical accompaniment where he types the expression in a symmetric fashion, culminating with the execution.<ref>DFunctionista. [https://www.youtube.com/watch?v=X3bv4Iu1aEg Palindromic Expression for Phi in APL]. YouTube. 2009-02-13.</ref>
Scholes then published a minute-long video with musical accompaniment where he types the expression in a symmetric fashion, culminating with the execution.<ref>DFunctionista. [https://www.youtube.com/watch?v=X3bv4Iu1aEg Palindromic Expression for Phi in APL]. YouTube. 2009-02-13.</ref>
== References ==
== References ==
<references />
<references />
[[Category:Examples]][[Category:Dyalog APL examples]]
[[Category:Examples]][[Category:Dyalog APL examples]]

Latest revision as of 22:25, 10 September 2022

Some find that APL expressions can have a poetic beauty. Phil Last submitted the following variable-free recursive dfn to compute the limit of a converging function, equivalent to the derived monadic operator ⍣≡:[1]

limit←{             ⍝ Function power limit (fixpoint).
    ⍵ ⍺⍺{           ⍝ 'old' value:
        ⍺≡⍵:⍵       ⍝       old matches new: finished.
        ⍵ ∇ ⍺⍺ ⍵    ⍝       otherwise: try new value.
    }⍺⍺ ⍵           ⍝ 'new' value.
}

John Scholes noted that it was close to being a palindrome, so he inlined it and he amended it with dummy code to make its invocation for finding the golden ratio even closer to palindromic:

      1{1+÷⍵}{⍵ ⍺⍺{⍺≡⍵:⍵ ⋄ ⍵ ⍺⍺ ∇∇ ⍺⍺ ⍵ ⋄ ⍵:⍵≡⍺}⍺⍺ ⍵}{⍵÷+1}1
1.618033989

Scholes then published a minute-long video with musical accompaniment where he types the expression in a symmetric fashion, culminating with the execution.[2]

References

  1. Dyalog. Function power limit (fixpoint). Dfns workspace. 2019-02-07.
  2. DFunctionista. Palindromic Expression for Phi in APL. YouTube. 2009-02-13.