You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even if named vars can be considered (a bite out of pure point-free).
# discriminant (with locally named args)
2 3 4 quo [c] def quo [b] def quo [a] def
b dup * 4 a * c * -
# >>> -23
## but the problem is that we really don't want args defined globally, so...
[a b c] [b dup * 4 a * c * -] [discriminant] define
2 3 4 discriminant
# >>> -23
The alternate pure point-free is a tangle of stack shufflers.
[a b c op] [b -1 * b b * 4 a * c * squareroot op 2 a * /] [quadratic-crossing]
[a b c] [a b c discriminant dup 0 < [[]] if dup 0 > [[ a b c [+] quadratic-crossing] ...] [] if-else] [quadratic]
manageable with the local-defined values (words) , but the stack swapping version is too complex to show here.
since define has matured into a useful construct with local-words, adding named-args
(e.g. named-args:[x y]) to consume stack arguments into getters to be used in the definition and local-words seem like an interesting enough idea to pursue.
{named-args: [a b c]
local-words: { discriminant: [ ... ] quadratic-crossing: [ ... ] ... }
definition: [a b c discriminant dup 0 < [[]] if dup 0 > [[ a b c [+] quadratic-crossing] ...]
} [quad] define
(e.g.
[m:number x:number b:number]
[m x * b +] [my-linear-function]
define-with-named-args
)
or how to implement the quadratic formula.
The text was updated successfully, but these errors were encountered: