2 ms·
I feel like there's a joke in here somewhere about a backwards Forth dialect, but this also reminds of of chaining idioms used in other languages. Currying wit
by saltcured 3y ago
I feel like there's a joke in here somewhere about a backwards Forth dialect, but this also reminds of of chaining idioms used in other languages.
Currying with OOP:
res = x
.mult(2)
.add(1)
.sub(3)
.mod(x)
Currying with assignment operators:
res = x
res *= 2
res += 1
res -= 3
res %= x
Naming things instead of Currying:
scale = 2
offset = 1 - 3
with_scale = x * scale
with_offset = with_scale + offset
result = with_offset % x
Or aping that in Scheme:
(let* ((scale 2)
(offset (- 1 3))
(with_scale (* x scale))
(with_offset (+ with_scale offset)))
(remainder with_offset x))