>>4 in O'Caml you can manage memory manually if you want
Cool, maybe I give it a try some day after all...
Name:
Anonymous2011-07-31 15:05
its the best option for statically typed functional languages, regular I/O instead of monads, very fast, lots of libraries, its the most useful functional language for making practial apps
the only thing I hate about it is the dot behind binary float operators +. -. *. /. that just looks shit awful, why couldnt they overload those operators like every other language?
Name:
Anonymous2011-07-31 15:06
>>8 the only thing I hate about it is the dot behind binary float operators +. -. *. /. that just looks shit awful, why couldnt they overload those operators like every other language?
Because they use type inference and don't have a numerical tower.
Name:
Anonymous2011-07-31 15:28
OCaml is French? not using it.
Name:
Anonymous2011-07-31 15:48
>>2 It has garbage collection, which sucks.
Lisp has garbage collection, in fact Lisp invented garbage collection
Program Fixpoint greater (n m : nat) : {n <= m } + {n > m } :=
match n, m with
| O, _ => left _ _
| S n', O => right _ _
| S n', S m' => if greater n' m' then left _ _ else right _ _
end.
Solve Obligations using auto with arith.
Name:
Anonymous2011-08-01 17:07
OCaml is dumb, i mean, why you need to declare if a function is recursive?
>>23 OCaml is dumb, i mean, why you need to declare if a function is recursive?
thats the point of OCaml, its not a pure functional language like Haskell, it allows a certain amount of imperative programming where needed. Whereas Haskell may be better for programming in a pure mathematical sense, it makes practical things inconvenient at times.
Name:
Anonymous2011-08-01 22:12
>>23
So you can do stuff like
let rec fact n = if n=0 then 1 else
let n = n*(n-1) in fact n (* <<-- For haskell, let n = n*(n-1) would not make sense. *)
Basically, you don't force recursive definitions every time you use let. Also, you don't have to make up new variable names all the time.
Name:
Anonymous2011-08-01 22:13
>>25
Oh wow, that is one awesome factorial algorithm.
let rec fact n z = if n=0 then z else
let z = z*n in fact (n-1) z
in
fact n 1
Fuxed.
Name:
Anonymous2011-08-01 23:31
O'Caml has the most interesting object system I have seen (not that I know many object languages). So if you like object stuff, you might like it. Though it's slow as shit if you use objects. So I would not recommend making small objects.
>>30 >>31
Lisp is shit. Lisp haters are shit. Be happy [spoiler]/bros/[/bros]
Name:
Anonymous2011-08-03 6:53
let rec extended_gcd a b =
if a > b then extended_gcd b a
else
if b = 0 then (1, 0)
else
let qr = divide a b;
let st = extended_gcd b (snd qr);
(snd st, (fun s q t -> s - q * t) (fst st) (fst qr) (snd st));;
All I receive is a sintax error. Where is this error?
let rec extended_gcd a b =
if a > b then extended_gcd b a
else
if b = 0 then (1, 0)
else
let qr = divide a b;
let st = extended_gcd b (snd qr);
(snd st, (fun s q t -> s - q * t) (fst st) (fst qr) (snd st));;
let rec extended_gcd a b =
if a > b then extended_gcd b a
else
if b = 0 then (1, 0)
else
let qr = divide a b in
let st = extended_gcd b (snd qr) in
(snd st, (fun s q t -> s - q * t) (fst st) (fst qr) (snd st))
;;
Also, this took me a while to figure out: If you are going to put multiple statements in an if block then you have to start with begin ... end. Ex:
let rec extended_gcd a b =
if a > b then extended_gcd b a
else
if b = 0 then (1, 0)
else begin
Printf.printf "a: %d b: %d" a b ;
let qr = divide a b in
let st = extended_gcd b (snd qr) in
(snd st, (fun s q t -> s - q * t) (fst st) (fst qr) (snd st))
end
;;