hsedit/examples/example2

27 lines
840 B
Text
Raw Permalink Normal View History

{
error = "0";
fact = { % number num -> number; set error if something is wrong
2016-08-29 11:39:26 +00:00
"num = a"
% num = "b"
2016-08-29 11:37:10 +00:00
continue = {} + ("test 1 -ge " + num).syscall;
[ continue = "0" :
[ {} + ("test 0 = " + num).syscall # "0" :
*error = "1";
]
^ "1";
]
nextnum = { in = *num + "-1"; } + "bc -lq".iosyscall;
[ nextnum.result = "0" :
result = { in = { num = **nextnum.out; } + **fact + "*" + *nextnum.out; } + "bc -lq".iosyscall;
[ result.result = "0" :
^ result.out;
]
]
*error = "2";
^ "0";
}
value = { num = "5"; } + fact;
[ error = "0" : { in = "result: " + *value; } + "echo".iosyscall; ]
[ error # "0" : { in = "error #" + *error; } + "echo".iosyscall; ]
}