Prequel
primitive recursive driven programming
(This example requires web workers.)
Sort these numbers in ascending order:
Shuffle: 10 73 45 32 98 25 17 33 88 61
←0
←0
←0
← calls
← instructions
← memory (max use: 0)
n := LISTSORT.INPUT.LENGTH REPEAT n   IF LISTSORT.INPUT[n-1] > LISTSORT.INPUT[n] LISTSORT.MOVE(n-1, n) ENDIF ENDREP
LISTSORT.INPUTAn unsorted list of numbers.-> e.g. [10, 73, 45, 32, 98, 25, 17, 33, 88, 61]MODULE.CALL.ARGSHolds the list of arguments passed with MODULE.CALL.-> [arg1, ..., argN]
LISTSORT.MOVE(fromIndex, toIndex)Move list element at index fromIndex to index toIndex.-> fromIndex: integer between 0 and LISTSORT.INPUT.LENGTH-1-> toIndex: integer between 0 and LISTSORT.INPUT.LENGTH-1Restart program counter.MODULE.CALL(&retvar1, ..., &retvarM, @modname, arg1, ..., argN)Start executing module modname, copying N arguments and expecting M return values.-> retvar: name of variable to hold the corresponding return value retval-> modname: name of module to start executing-> arg: value to be copied to the list MODULE.CALL.ARGSAlternative syntax: retvar1, ..., retvarM := MODULE.CALL(@modname, arg1, ..., argN)Note that recursive module calls are not allowed.MODULE.RETURN(retval1, ..., retvalM)Return M values from the current module.Resume execution at the next instruction of the corresponding MODULE.CALL.-> retval: value to be copied to the corresponding variable retvar