3 ms·
Ok, the thing I hadn’t worked out when I wrote the above is that this is also APL-like, which is pretty fun. It feels like the main missing feature is some way
by dan-robertson 2y ago
Ok, the thing I hadn’t worked out when I wrote the above is that this is also APL-like, which is pretty fun. It feels like the main missing feature is some way to do grouping, though I’m not sure. I tried translating my first two examples but I didn’t try executing them so they mightn’t work:
(->2)"(->1)~.*{|`2.`0}
"(\g. g.((+)|0 {g=`2}{`3})) ~. $2
I think I might also be missing something about the ` operator: the first example feels a bit strained because it first needs to put fields in a tuple then extract from the tuple. I feel like I want $0 to give a list of some records that can be converted to strings but which can also have fields extracted. Then the example might look like (`1)~.*$0. I don’t know if the $0 could be implicit too. Another horrible feature would be integers to be coerced into functions if needed – take the nth field from a record/list/tuple.
I’m not sure I really understand the language (and I definitely don’t understand the implementation!) but it seems pretty interesting. Perhaps a better motto than “functional awk” is “streaming APL with type checking (and type classes)”?