First-class functions: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: spelling) |
(add BQN) |
||
Line 504: | Line 504: | ||
0.4999999999999999 |
0.4999999999999999 |
||
0.5000000000000001</lang> |
0.5000000000000001</lang> |
||
=={{header|BQN}}== |
|||
BQN has full support for first class functions in the context of this wiki page. A more detailed article on BQN's implementation of functional programming is discussed [https://mlochbaum.github.io/BQN/doc/functional.html here]. |
|||
<code>∘</code>(Atop) is used here to compose the two lists of functions given. Higher order functions are then used to apply the functions on a value. There is a slight change in value due to floating point inaccuracy. |
|||
BQN has provisions to invert builtin functions using <code>⁼</code>(Undo), and that can also be used for this demonstration(<code>funsB ← {𝕏⁼}¨ funsA</code>). |
|||
<lang bqn>funsA ← ⟨⋆⟜2,-,•math.Sin,{𝕩×3}⟩ |
|||
funsB ← ⟨√,-,•math.Asin,{𝕩÷3}⟩ |
|||
comp ← funsA {𝕎∘𝕏}¨ funsB |
|||
•Show comp {𝕎𝕩}¨<0.5</lang> |
|||
<lang bqn>⟨ 0.5000000000000001 0.5 0.5 0.5 ⟩</lang> |
|||
[https://mlochbaum.github.io/BQN/try.html#code=ZnVuc0Eg4oaQIOKfqOKLhuKfnDIsLSzigKJtYXRoLlNpbix78J2VqcOXM33in6kKZnVuc0Ig4oaQIOKfqOKImiwtLOKAom1hdGguQXNpbix78J2VqcO3M33in6kKCmNvbXAg4oaQIGZ1bnNBIHvwnZWO4oiY8J2Vj33CqCBmdW5zQgoK4oCiU2hvdyBjb21wIHvwnZWO8J2VqX3CqDwwLjU= Try It!] |
|||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |