/*
In assembly all type is an integer
they are unsigned. and have function who can act as signed
they can be splited into 8bits 16bits and 32bits partitions
in the end, it all a chain of bytes with complete binary controls
pointer? you guessed it, mov di,ax call [di]

In functional, all value are function, everything is a function
and value are function returning it self. reconised as value by its pointer
and value are also atom, string, number, object, function
Variable are declared using a single command : let var => something
variable are immutable, they are not even called variable

Low level functional c
Let declare the most universal type, 8bits unsigned integral
*/
typedef unsigned char Let;

/*
List manipulation

in assembly, you only have one big array of int
and access directly to it by index.

in functional, list are single linked list
they can grow or shrink, and can only be iterated forward

low level functional c
Let [] is a concise array usage
all array must be declared were it is used
because they are mutable, no malloc , 
no array passing by return
*/
#define First(LST) (LST[0])
#define Rest(LST) (&LST[1])
void Clear(Let[]);
void Range(Let[], Let end);
void Fill(Let[], Let end, Let val);
void Take(Let[], const char *); //just copy a const array into another
void Permute(Let[]);//once all character unit 0 permute to the right one cell

/*
high order function
*/
typedef Let (*Funk)(Let, Let[]); 
void Transform(Let[], Funk); //Map funk(first:rest),
void Predicate(Let[], Funk); //Filter funk(first:rest), 
void Aggregate(Let[], Funk); //Reduce funk(acc, rest), overwrite first element
void Enumerate(Let[], Funk); //(index, array)
void Generate(Let[], Funk); //(index, array) while funk yield not 0 or initial not 0
void Sort(Let[], Funk); //funk(elem, subarray) return any from sub array to reorder
typedef void (*Hof)(Let[],Funk); //interface for chaining

Let Max(Let, Let);
Let Min(Let, Let);
typedef Let (*Zip)(Let, Let);
void Combine(Let[], Let[], Zip);
void Filter(Let[], Let[], Zip);

/* 
continuation passing style
cheat with the no array passing by return 
*/
typedef struct Continuation * Co;
typedef void (*Routine)(Co);
struct Continuation {
	Routine routine;
	Let * llection;
};
void Do(Routine,Let[]);
/*
IO
orthogonal persistance
*/
Let Cerealize(Let);
Let Decerealize(Let);
/* binary array */

/* 2d array */
Let Cell(Let w, Let col, Let row); //game love 2d arrays 
Let Col(Let w, Let offset);
Let Row(Let w, Let offset);

/* number 
hex ? 1234567890E10
E mean exponent
A B C D or F are candidate for minus sign
room for periodic
number are between 0-9
increased cost of calculation yield great stability and control

*/
void Add(Let [], const Let []);
void Sub(Let [], const Let []);
void Mul(Let [], const Let []);
void Div(Let [], const Let []);
void Mod(Let [], const Let []);
void Pow(Let [], Let);

/*
nand neural net
*/

/*
idempotent logarithm algorithm 
with one 30 microops multiplication 
and three one microops operation
f(a) -> ( a | 1 ) * ( ++a >> 1 )
yield 1 3 6 10 15 21 28 32 40 ...
*/
