# ANN: heavy updates to inca, apl calculator in (overly-)terse C

Discussion in 'C Programming' started by luser droog, May 4, 2014.

1. ### luser droogGuest

The inca interpreter has incorporated strange new features
in the area of programmability and accessibility.
It is available in an online version compiled to javascript
courtesy of Thomas Baruchel http://baruchel.hd.free.fr/apps/apl/inca/
as well as the master repo
https://github.com/luser-dr00g/inca

Essentially, the change over the previous announcement is
the new "command-string" type, and special-syntax functions
to make more use of it.

The new colon special monadic function consumes the remaining
subexpression's code representation in an array. Thus

f<:x+y

Sets f to the function x+y. f may be called as a procedure,
where x and y refer to global variables with the semicolon
(execute operator)

x<2
y<3
;f
5

Or, it may be called functionally, where x and y refer to
local arguments with the double-quote function.

2"f3
5

Or, a monadic function, using only the y argument may be
called with the single-quote function.

g<:y*2
'g3
9

The quote and double-quote functions also accept (as special
syntax) a parenthesized expression in place of the variable
(or other expression yielding the command-string-type array).
This expression may use x and y as arguments as with a
"named" function.

'(y*2)3
9

And this presents enough to define recursive functions,
like Fibonacci:

f<:;(y>1){(<:1);<'fy-1)+'fy-2

Where the brace { is the "from" function, or [index]array,
and here the index is a Boolean zero or one which indexes
two expressions, :1 and 'fy-1)+'fy-2. These are boxed
with angle-bracket < so they can be combined into a
single array with semicolon ; to be selected from.

The interpreter also defines the variable a to contain
a boxed-array of command-string arrays which represent
the argv strings passed to the program, allowing inca
to access external data files via shell `cat ...` expansion.

The C code is getting pretty gawdoffal, but the language
itself is proving to be lots of fun to play with. YMMV.

luser droog, May 4, 2014