Enkidu said:
Because they are a good basis to move to GWBasic.
In GWBasic this is a complete program:
10 Print "Hullo World"
This would require up to a dozen lines of declarations and other
unnecessary rubbish in any other language.
Just:
printf "Hullo World"
in F#.
This is a loop in GWBasic:
10 Print "Hullo World"
20 GOTO 10
Succinct, does what you need with a minimum of fuss.
Absolutely. This is an interpreter for a dynamically-typed functional
programming language written in F#:
let rec eval vars = function
| EApply(func, arg) -> begin match eval vars func, eval vars arg with
| VClosure(var, vars, body), arg -> eval ((var, arg) :: vars) body
| _ -> invalid_arg "Attempt to apply a non-function value"
end
| EAdd(e1, e2) -> VInt (int(eval vars e1) + int(eval vars e2))
| EMul(e1, e2) -> VInt (int(eval vars e1) * int(eval vars e2))
| EEqual(e1, e2) -> VBool (eval vars e1 = eval vars e2)
| EIf(p, t, f) -> eval vars (if bool (eval vars p) then t else f)
| EInt i -> VInt i
| ELetRec(var, arg, body, rest) ->
let rec vars = (var, VClosure(arg, vars, body)) :: vars in
eval vars rest
| EVar s -> List.assoc s vars;;