quernd80 has quit [Quit: Ping timeout (120 seconds)]
quernd80 has joined #ocaml
<src>
alright I made it tail recursive, but I still don't know why the pasted 'take' function isn't creating a stack overflow? Is OCaml applying some optimization to it?
Tuplanolla has quit [Quit: Leaving.]
sand_dull has joined #ocaml
quernd80 has quit [Quit: Ping timeout (120 seconds)]
sand_dull has quit [Remote host closed the connection]
<discocaml>
<rland> problem is basically: given a list of ints, return the maximum difference between two ints where the larger number is on the right of the smaller number
<discocaml>
<rland> for example:
<discocaml>
<rland> [7, 1, 5, 4] -> 4
<discocaml>
<rland> [1, 5, 2, 10] -> 9
<discocaml>
<rland>
<discocaml>
<rland> here is my solution below
<discocaml>
<rland> ```ml
<discocaml>
<rland> let biggest_diff lst =
<discocaml>
<rland> let rec aux min_so_far res = function
<discocaml>
<rland> | [] -> if res = 0 then -1 else res
<discocaml>
<rland> | h :: t -> if h < min_so_far
<discocaml>
<rland> then aux h (max (h - min_so_far) res) t
<discocaml>
<rland> else aux min_so_far (max (h - min_so_far) res) t
<discocaml>
<rland> in aux Int.max_int 0 lst
<discocaml>
<rland> ```
<discocaml>
<rland> I feel like my solution is needlesly complex for such a simple problem. Is there anything I could be using that reduces the amount of code/makes it more readable?
<companion_cube>
plz don't post big code snippets here :/
<discocaml>
<rland> sorry if this is really bad code, I am pretty much brand new to OCaml
<companion_cube>
this looks like a List.fold_left could do though?
<companion_cube>
(with the pair `(min_so_far, res)` as folded accumulator)
average has joined #ocaml
chrisz has quit [Ping timeout: 255 seconds]
chrisz has joined #ocaml
<discocaml>
<raven49_07> Hello everyone , I am trying to setup the dark mode ocaml.org project , but I am getting an error , Somebody please help me set up the project.
<discocaml>
<hockletock> did you already "make switch" @raven49_07 ?
waleee has quit [Ping timeout: 258 seconds]
peony has joined #ocaml
domq has joined #ocaml
waleee has joined #ocaml
waleee has quit [Ping timeout: 240 seconds]
kaptch has joined #ocaml
kaptch has quit [Client Quit]
azimut has joined #ocaml
zozozo has quit [Ping timeout: 255 seconds]
<discocaml>
<raven49_07> yes i had this error when i gave the make switch command
<discocaml>
<raven49_07> i also changed the linux distribution service from ubuntu to debian and then re run the whole build , I am again having some error .