#!/home/trizer/Hobby/lisp_v2/build/playLisp
#Operations
setq functions
(quote (
(func (a b)(+ a b))
(func (a b)(- a b))
(func (a b)(* a b))
(func (a b)(/ a b))
));
#Operation names
setq func_names (quote
(
"sum"
"sub"
"mul"
"div"
)
);
defun main (a)
{
while T
{
setq tmp func_names;
setq i 1;
while (!= tmp nil)
{
print i ". " (car tmp);
setq tmp (cdr tmp);
setq i (+ i 1);
};
print i ". Exit";
setq n (ask "Enter n: " );
if (|| (< n 1) (> n i))
{
print "Bad number, repeat please";
continue;
};
if (== n i) (return 1);
setq a (ask "Enter a: ");
setq b (ask "Enter b: ");
setq tmp functions;
while (!= n 1)
{
setq tmp (cdr tmp);
setq n (- n 1);
};
print "Result = " ((exec (exec (car tmp))) a b);
};
};
main 0;