companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
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]
quernd80 has joined #ocaml
<discocaml> <rland>
<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.
average has quit [Quit: Connection closed for inactivity]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
ec has quit [Remote host closed the connection]
ec has joined #ocaml
mro has joined #ocaml
Serpent7776 has joined #ocaml
mro has quit [Remote host closed the connection]
bartholin has joined #ocaml
mro has joined #ocaml
domq has joined #ocaml
azimut has quit [Ping timeout: 252 seconds]
peony has quit [Read error: Connection reset by peer]
dnh has joined #ocaml
domq has quit [Quit: domq]
domq has joined #ocaml
domq has quit [Quit: domq]
dnh has quit [Quit: Textual IRC Client: www.textualapp.com]
dnh has joined #ocaml
waleee has joined #ocaml
<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 .
<discocaml> <raven49_07> please somebody help me setup the project
mro has quit [Remote host closed the connection]
sand_dull has joined #ocaml
sand_dull has quit [Remote host closed the connection]
Serpent7776 has quit [Ping timeout: 255 seconds]
domq has quit [Quit: domq]
domq has joined #ocaml
domq has quit [Quit: domq]
sand_dull has joined #ocaml
sand_dull has quit [Remote host closed the connection]
domq has joined #ocaml
domq has quit [Ping timeout: 264 seconds]
domq has joined #ocaml
zozozo has joined #ocaml
wingsorc has joined #ocaml
Tuplanolla has joined #ocaml
bartholin has quit [Quit: Leaving]
hsw_ has joined #ocaml
domq has quit [Ping timeout: 248 seconds]
domq has joined #ocaml
hsw has quit [Read error: Connection reset by peer]
alphacentauri has quit [Quit: WeeChat 4.0.5]
alphacentauri has joined #ocaml
domq has quit [Quit: domq]
zozozo has quit [Ping timeout: 260 seconds]
zozozo has joined #ocaml
dnh has quit [Ping timeout: 245 seconds]
alphacentauri has quit [Quit: WeeChat 4.0.5]
alphacentauri has joined #ocaml
dnh has joined #ocaml
dnh has quit [Ping timeout: 240 seconds]
waleee has joined #ocaml
chrisz has quit [Ping timeout: 252 seconds]
chrisz has joined #ocaml