I spent some time working on my language (temporary name: KAP)

I've implemented first-class functions, which is something that is not typically available in APL. I.e. you can, for example, have an array of functions.

The temporary syntax is as follows. The following assigns a lambda function to the variable foo:

foo ← λ { ⍵+1 }

This is different from traditional function definition which is similar, but does not include the lambda symbol. The difference is while the traditional syntax declares foo to be a function, the KAP syntax declares foo to be a variable holding a scalar value, a function.

You use the symbol ⍞ to dereference a lambda function. It's used like so:

⍞foo 10

Now, the semantics of function dereference is not great. It actually binds strongly to the next argument, which is why it's parsed as ⍞foo) 10 rather than ⍞(foo 10). This goes against the rest of the language which always parses right to left.

Is there a better way to express function dereference that I haven't thought of? Please provide suggestions if you have any.

Also, one may ask why I chose to use ⍞. There is no good answer to that, other than the fact that KAP does not implement the traditional functionality of ⍞ so the symbol was available. If anyone has a suggestion for a better symbol, I'd be happy to hear it.

Follow

If anyone wants to look at the code, it's here:

github.com/lokedhs/array

If you want to run the (very rudimentary) user interface, you can start it using: ./gradlew run

Sign in to participate in the conversation
Functional Café

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!