Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

O'Caml

Name: Anonymous 2011-07-31 14:16

Good day, fellow /prog/raiders.
I am currently learning O'Caml, what should I pay attention? What is Bad and what is Good on this language?

Name: Anonymous 2011-07-31 14:21

It has garbage collection, which sucks.

Other than that, it's OK, I guess.

Name: Anonymous 2011-07-31 14:22

It has nothing fundamentally bad, or fundamentally good. It's OK.

Ignore >>2,he's the troll of the week.

Name: OP 2011-07-31 14:25

>>3
>>2
I know GC is shit, but IMO in O'Caml you can manage memory manually if you want.

Name: Anonymous 2011-07-31 14:32

>>4
O'Caml
It's not Irish, it's French. Also, IMO makes no sense in that sentence.

Name: Anonymous 2011-07-31 14:42

>>4
but IMO in O'Caml you can manage memory manually
That's not really an opinion.

Name: >>2 2011-07-31 14:56

>>4
in O'Caml you can manage memory manually if you want

Cool, maybe I give it a try some day after all...

Name: Anonymous 2011-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: Anonymous 2011-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: Anonymous 2011-07-31 15:28

OCaml is French? not using it.

Name: Anonymous 2011-07-31 15:48

>>2
It has garbage collection, which sucks.
Lisp has garbage collection, in fact Lisp invented garbage collection

Name: Anonymous 2011-07-31 15:56

>>1
This means that Lisp invented sucking!

Name: Anonymous 2011-07-31 16:04

>>5
It's not Irish, it's French.
ocaml is a dialect of ML, so its really Scotish

Name: Anonymous 2011-07-31 16:12

>>5
>>7
*IIRC, im trippin balls

Name: Anonymous 2011-07-31 16:25

>>10
OCaml is French? not using it.
Be careful to avoid Prolog, Bigloo, Coq and Scilab.

Name: Anonymous 2011-07-31 16:27

Coq:
  Worst or best name for a programming language ever?

Name: Anonymous 2011-07-31 16:28

>>15
and Eiffel.

Name: Anonymous 2011-07-31 18:01

>>15
and Ada

Name: ( ≖‿≖) 2011-07-31 18:20

>>15
And Surrender.

Name: Anonymous 2011-07-31 21:44

Be careful not to break the OCaml's back.

Name: Anonymous 2011-08-01 6:38

Ignore all object bullshit and just treat it as a bastardised Standard ML.

Name: Anonymous 2011-08-01 7:29

Here's some glorious Coq code, a solution for http://adam.chlipala.net/cpdt/ exercise 6.6.1

Require Import Arith.

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: Anonymous 2011-08-01 17:07

OCaml is dumb, i mean, why you need to declare if a function is recursive?

Name: Anonymous 2011-08-01 19:13

>>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: Anonymous 2011-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: Anonymous 2011-08-01 22:13

>>25
Oh wow, that is one awesome factorial algorithm.

Name: Anonymous 2011-08-01 22:13

>>25
OTL

Name: Anonymous 2011-08-01 22:17


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: Anonymous 2011-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.

Name: Anonymous 2011-08-02 7:38

If it ain't Lisp it's crap.

Name: Anonymous 2011-08-02 8:21

If it's Lisp, it's for faggots.

Name: Anonymous 2011-08-02 8:22

>>31
If it's you, it is.

Name: Anonymous 2011-08-02 8:46

>>32
If it's my post, it's dubz.

Name: ( ≖‿≖) 2011-08-02 15:17

>>30
>>31
Lisp is shit. Lisp haters are shit. Be happy [spoiler]/bros/[/bros]

Name: Anonymous 2011-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?

Name: Anonymous 2011-08-03 7:26

>>35
sintax
There, it should be syntax.

Name: Anonymous 2011-08-03 7:46

Dangling else problems don't happen in Lisp.

Name: Anonymous 2011-08-03 7:48

>>35
>>36

That is a lexic error. No, it's not lexyc.

Forgot my code tags.


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));;

Name: Anonymous 2011-08-03 7:53

>>38
Also, divide is
let divide x y = x / y, x mod y;;
and i took the algorithm directly from http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Recursive_method_2

Name: Anonymous 2011-08-03 8:38

>>38,39
It's always let x = 3 in. Not let x = 3;


let divide x y = x / y, x mod y ;;

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
;;

Name: Anonymous 2011-08-03 11:44

>>40
Ok, thank you, that did the work.
I didn't understand the meaning of in until that.

Name: Anonymous 2011-08-05 14:38

Functors are the coolest thing in Ocaml.

Name: Anonymous 2011-08-05 14:44

>>42
That's not a good thing.

Name: Anonymous 2011-08-05 15:20

>>43
You're not a good thing.

Don't change these.
Name: Email:
Entire Thread Thread List