Hi!
I'm working on a Lisp dialect in F# and I have a problem. There is a strange bug. I'm working on a rule processing engine which will be based on the progn command. Rules would be functions created with the fun command.
If I evaluate the following expressions, one of them has a correct result the othes does not. The evaluation of the progn command is correct if the first argument is not function creation. Also function creation works fine in other places.
Code for the progn operation:
let expr_op_progn (expr : Expr list) (ctx : Context) =
ExprList( List.map (fun l -> eval ctx l |> fst) expr ) ;;
Exmple:
let fun_test = prase_expr "( progn ( + 3 1 )
( fun () ( + 3 14 ) )
( - 3 2) )" ;;
let fun_test1 = prase_expr "( progn ( fun () ( + 3 14 ) )
( - 3 2) )" ;;
Function creation is the second argument.
let a,b = eval initial_ctx fun_test ;;
The result expression is correct:
ExprList [ExprInt 4; ExprFunction <fun:expr_spec_fun@65>; ExprInt 1]
Function creation is the first argument.
let d,c = eval initial_ctx fun_test1 ;;
The result expression is incorrect: ExprInt 17
I would upload or attach the code for the Lisp implementation if someone specifies where...
Thanks in advance.