3 ms·
In a somewhat similar vein, I made a concatenative array language inspired by kdb+/q: https://cryptm.org/xs/ https://cryptm.org/xs/ Unlike other concatenative
by smabie 6y ago
In a somewhat similar vein, I made a concatenative array language inspired by kdb+/q: https://cryptm.org/xs/ https://cryptm.org/xs/
Unlike other concatenative languages, the order of operation is right to left, and it supports infix operators. This gives the language a very conventional array language feel, while also giving you the power and flexibility of the stack.
As far as I'm aware, there's really nothing like it. Would love if someone gave it a try!
Here's an example, the factorial function:
xs> fac:(prod 1+til);
xs> fac 4
0: 24
You can also define new infix operators:
xs> add:{+.};
xs> 3 add 2
0: 5
Here's an example of generating a sequence of values, where n_t=n_{t-1}/2:
xs> (x:;x%2) fixes 12
0: [12 6 3 1 0]
Note how when we reach the fixpoint of zero, the recursion stops. These kinds of implicitly recursive combinators are very powerful. Also, equality on floats is not strict, so we can also do this with floats, without having to worry about small differences in precision. This is useful when working with equation optimizers and root finding methods.
- wvlia5 6y agolooks cool, like the ideal language I would like to write for boosting popularity: 1- would be nice to use in tryit online or repl.it 2- would be nice to have a link to the implementation repo in the docs 3- have you tried winning some golfscript contests on stack overflow? 4- main improvements over K, with small code samples?
- smabie 6y agoI do have some examples in the examples section. There's a link to the OCaml implementation on the page as well. A repl.it would be awesome, I'll definitely do that. I hadn't heard of golfscript, but those would make some really great examples. I do have a couple Advent of Code 2019 solutions though. Thanks!