I was going to see how slow Felix was so I wrote this in Ocaml: let ls = ref [1;2] ;; for i= 0 to 20 do ls := !ls @ !ls; print_endline (string_of_int (List.length !ls)); done ;;
~/felix>./clr 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 Fatal error: exception Stack_overflow What? Ocaml can't concatenate a list of 1 Meg elements? Admittedly it crashed almost instantly: faster than Felix. But still: ~/felix>flx --test=build/debug/ lr 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 [killed after a few minutes waiting .. slow due to bad GC tuning?] So this does better: let ls = ref [1;2] ;; for i= 0 to 25 do ls := List.rev (List.fold_left (fun acc x -> x::acc) (List.rev !ls) (!ls)); print_endline (string_of_int (List.length !ls)); done ;; Since it's tail rec. Still, it shows how naive some of the Ocaml ops are. Felix uses roughly that algorithm, except the reversal is done "in place" since it's known there can't be any sharing. Same for map: it's done with a rev_map followed by an inplace reversal. Again, because the new list created can't be shared by anyone, mutation is safe. -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language