3 ms·
What exactly is this?
by mcphage 1y ago
What exactly is this?
- Jtsummers 1y agohttps://en.wikipedia.org/wiki/Tacit_programming https://en.wikipedia.org/wiki/Tacit_programming Tacit programming basically means constructing new function/routines without introducing explicitly named parameters. In an ML-family language, you can construct `double` with something like: double = 2* Partial application of the binary function * means we don't need to be explicit like this: double x = 2 * x The linked Prolog is implementing an interpreter for a Forth-like language. Forths let you do tacit programming via operations on the stack. The above example, in Forth, would be: : double dup + ; : double 2 * ; Neither of which has an explicit variable. The first duplicates the top of the stack then adds the top two items on the stack, the second pushes 2 onto the stack and then multiplies the top two items. If you copy/paste the gist into the site below you can play around with the program stored in `main`. Change `main` to just: main --> mul, add. With the query `main(R).` you'll get a result of `R = 1*2.`. Add each instruction one at a time and re-execute the query. The result will always be the top of the stack, before the last `is_` you'll get this: R = abs(5^(pi-5)). Which is then processed by the last `is_` into the result, 0.05023... https://play.scryer.pl/ https://play.scryer.pl/
- mcphage 1y agoAh, now I understand. Thank you!