Source file values.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
open Types

let rec show_evt_fancy e = match e with
  | EvtUnit -> "()"
  | EvtInt v -> string_of_int v
  | EvtFloat v -> Printf.sprintf "%F" v
  | EvtComplex n -> show_complext n
  | EvtBool v -> string_of_bool v
  | EvtChar c -> "'" ^ String.make 1 c ^ "'"
  | EvtString v -> "\"" ^ (String.escaped v) ^ "\""
  | EvtVect (_, l) -> "[|" ^ (String.concat ", " (Array.map show_evt_fancy l |> Array.to_list)) ^ "|]"  
  | EvtList l -> "[" ^ (String.concat ", " (List.map show_evt_fancy l)) ^ "]"
  | EvtDict d -> "{" ^
                 (String.concat ", " 
                    (List.map (fun (x,y) -> x ^ " = " ^ show_evt_fancy y) d))
                 ^ "}"
  | Closure (name, param, body, _) ->
    (match name with | Some x -> x | None -> "") ^ "(fun " ^ (String.concat " " (param::(Expr.findparams body))) ^ " -> ... )"
  | LazyExpression e -> "<lazy>: " ^ (Expr.show_expr_short e)

(** Function that creates a list with the params of a nested lambda in a Closure *)
let findevtparams l = match l with
  | Closure(_, p, b, _) -> p::(Expr.findparams b)
  | _ -> []