adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.07.1 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.07/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml | Due to ongoing spam, you must register your nickname to talk on the channel
MarcWeber has joined #ocaml
slamzy12345 has quit [Ping timeout: 256 seconds]
Bronsa` has joined #ocaml
iAmDecim_ has quit [Ping timeout: 260 seconds]
iAmDecim_ has joined #ocaml
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
ziyourenxiang has joined #ocaml
Bronsa` has quit [Ping timeout: 252 seconds]
mwgkgk has quit [Quit: Connection closed for inactivity]
jjmeyer0 has joined #ocaml
jjmeyer0 has quit []
jjmeyer0 has joined #ocaml
malina has joined #ocaml
ygrek__ has quit [Ping timeout: 240 seconds]
mfp has quit [Ping timeout: 244 seconds]
jjmeyer0 has quit [Ping timeout: 268 seconds]
slamzy12345 has joined #ocaml
slamzy1234 has joined #ocaml
slamzy12345 has quit [Ping timeout: 256 seconds]
pzp has quit [Quit: Connection closed for inactivity]
tormen has joined #ocaml
tormen_ has quit [Ping timeout: 250 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 268 seconds]
malina has quit [Ping timeout: 268 seconds]
pierpal has quit [Read error: Connection reset by peer]
malina has joined #ocaml
slamzy1234 has quit [Ping timeout: 256 seconds]
malina has quit [Ping timeout: 246 seconds]
jao has quit [Ping timeout: 250 seconds]
kalio has quit [Ping timeout: 245 seconds]
kalio has joined #ocaml
kakadu has joined #ocaml
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 268 seconds]
nullifidian has quit [Remote host closed the connection]
nullifidian has joined #ocaml
nullifidian has quit [Ping timeout: 250 seconds]
iAmDecim_ has quit [Ping timeout: 246 seconds]
nullifidian has joined #ocaml
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 268 seconds]
pierpal has joined #ocaml
Desetude has joined #ocaml
pierpal has quit [Ping timeout: 244 seconds]
<Desetude> Hi all, I have the following function: https://gist.github.com/Desetude/99b9d4846860484c66a967adcaaca3ee (I know it's terrible, it's the first function I've created in Ocaml). But I get "This expression has type 'a list but an expression was expected of type int" in the last argument of the recursive call on the last line
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 250 seconds]
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 246 seconds]
pierpal has joined #ocaml
pierpal has quit [Ping timeout: 246 seconds]
<sonologico> Desetude, I just pasted it into utop and it compiles for me. I only get warnings about non exhaustive matches
orbifx3 has joined #ocaml
<Desetude> sonologico: As you said that, I found the problem, it's because I had the args in List.mem the wrong way round so the type inferencing was getting confused
<Desetude> It seems like Base does List.mem the other way round to some other libs? I'm not really sure
<sonologico> yes, the stdlib one uses the order that in your original code
<Desetude> ah ok that's a bit annoying
<sonologico> I just removed the ~equal:(=) to use the stdlib one when I pasted
<Desetude> ok thanks. Which list is it talking about with the non exhaustive matches?
<Desetude> or is it both
pierpal has joined #ocaml
asymptotically has joined #ocaml
<sonologico> Desetude, both
FreeBirdLjj has joined #ocaml
bartholin has joined #ocaml
<sonologico> in the function argument list, you're doing something like (h :: t) for both arguments. The warning is saying that you're not considering [] (the empty list)
pierpal has quit [Ping timeout: 240 seconds]
<sonologico> so you'll get an error if your function is called like `find_first_duplicate_sum [] []`
pierpal has joined #ocaml
jnavila has joined #ocaml
pierpal has quit [Ping timeout: 246 seconds]
pierpal has joined #ocaml
clog has quit [Ping timeout: 240 seconds]
clog has joined #ocaml
mfp has joined #ocaml
Guest27648 has joined #ocaml
Guest27648 has quit [Remote host closed the connection]
pierpal has quit [Read error: Connection reset by peer]
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
kalio has quit [Ping timeout: 246 seconds]
orbifx3 has quit [Ping timeout: 250 seconds]
kalio has joined #ocaml
Haudegen has joined #ocaml
orbifx3 has joined #ocaml
orbifx3 has quit [Ping timeout: 246 seconds]
ggole has joined #ocaml
jao has joined #ocaml
tane has joined #ocaml
mjanssen has left #ocaml [#ocaml]
FreeBirdLjj has quit [Remote host closed the connection]
tane_ has joined #ocaml
tane has quit [Quit: Leaving]
FreeBirdLjj has joined #ocaml
slamzy1234 has joined #ocaml
kakadu has quit [Remote host closed the connection]
slamzy1234 has quit [Ping timeout: 256 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
jao has quit [Ping timeout: 250 seconds]
iAmDecim_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 250 seconds]
pierpal has joined #ocaml
olle has joined #ocaml
orbifx3 has joined #ocaml
FreeBirdLjj has joined #ocaml
tane_ has quit [Quit: Leaving]
orbifx3 has quit [Quit: WeeChat 2.1]
FreeBirdLjj has quit [Ping timeout: 268 seconds]
MadcapJake has quit [Remote host closed the connection]
tane has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 250 seconds]
ziyourenxiang has quit [Ping timeout: 268 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 268 seconds]
Desetude has quit [Quit: WeeChat 2.3]
oliverfriedmann has joined #ocaml
FreeBirdLjj has joined #ocaml
Bronsa` has joined #ocaml
jao has joined #ocaml
marvin3 has joined #ocaml
marvin2 has quit [Ping timeout: 250 seconds]
iAmDecim has joined #ocaml
iAmDecim_ has quit [Ping timeout: 252 seconds]
fraxamo has joined #ocaml
asymptotically has quit [Quit: Leaving]
wagle has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
wagle has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
slamzy1234 has joined #ocaml
malina has joined #ocaml
malina has quit [Remote host closed the connection]
Bronsa` has quit [Ping timeout: 252 seconds]
Haudegen has quit [Remote host closed the connection]
olle has quit [Ping timeout: 245 seconds]
iAmDecim has quit [Ping timeout: 250 seconds]
MadcapJake has joined #ocaml
zolk3ri has joined #ocaml
kakadu has joined #ocaml
pierpal has quit [Ping timeout: 268 seconds]
oliverfriedmann has quit []
ggole has quit [Quit: ggole]
Haudegen has joined #ocaml
Birdface has joined #ocaml
olle has joined #ocaml
Jesin has joined #ocaml
asymptotically has joined #ocaml
asymptotically has quit [Remote host closed the connection]
asymptotically has joined #ocaml
kark has joined #ocaml
pierpal has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
Birdface has quit [Ping timeout: 268 seconds]
olle has quit [Remote host closed the connection]
kakadu has quit [Ping timeout: 246 seconds]
kakadu_ has joined #ocaml
so has quit [Ping timeout: 246 seconds]
fraxamo has quit [Quit: Leaving]
so has joined #ocaml
drewr has quit [Remote host closed the connection]
tanelso2 has joined #ocaml
tanelso2 has left #ocaml [#ocaml]
tanelso2 has joined #ocaml
<tanelso2> Hello everyone! I am learning OCaml by doing Advent of Code puzzles. I solved the day1 puzzles, but my code takes 30-40 seconds to find the solution and I'm not really sure why.
<companion_cube> can you show us the code?
<tanelso2> I am a complete newbie to Ocaml so I'm sure I'm doing something wrong or very inefficiently
<companion_cube> part1 seems fine
<tanelso2> Yeah part1 runs quickly
<tanelso2> It's part2 I had trouble with
<companion_cube> ah, you shouldn't use Set.exists for that
<companion_cube> there must be a Set.mem or Set.contains
<companion_cube> (I don't know Core much, but it's the whole point of Set)
<companion_cube> that'd turn your O(n) lookup into a O(ln(n))
<companion_cube> otherwise, the code looks pretty good, except (imho) for the 4 spaces indent
<companion_cube> you may want to use ocp-indent :)
<Drup> even if the List version, List.mem is a thing.
<companion_cube> yeah but it's not very useful since it uses polymorphic equality
<companion_cube> I'd say it's a code smell in 2018 :)
<tanelso2> I completely skipped over List.mem while looking through the docs. Alright thanks for the hint
<tanelso2> Oh there is a Set.mem
<companion_cube> yes, it's pretty important
<companion_cube> also, Set.union, etc.
<tanelso2> Interesting. Why is it called mem btw? I'm used to languages that call it contains or something similar
<companion_cube> wow ok this does 130,300 iterations for me… didn't realize it was so computational
<companion_cube> tanelso2: `member`
<companion_cube> and it's `mem x set` (x member of set) rather than `contains set x`
<companion_cube> in this particular interface
<tanelso2> Ah makes sense
<tanelso2> Yeah it is a TON of iterations
<tanelso2> Wasn't sure if there were more efficient ways to write this that handles the iterations better.
<tanelso2> Maybe a data structure similar to Clojure's transients? Not familiar enough with OCaml yet
<tanelso2> Wait nevermind
<tanelso2> Set.mem took the time down from 45 seconds to 0.08s
<tanelso2> Awesome. Thanks for the help everyone!
<tanelso2> I will probably be back with more questions in the coming weeks
<companion_cube> no pb, good luck tanelso2!
Birdface has joined #ocaml
al-damiri has joined #ocaml
tanelso2 has quit [Ping timeout: 245 seconds]
jnavila has quit [Ping timeout: 272 seconds]
iAmDecim has joined #ocaml
kakadu_ has quit [Remote host closed the connection]
tanelso2 has joined #ocaml
Jesin has quit [Quit: Leaving]
tanelso2 has quit [Ping timeout: 245 seconds]
Birdface has quit [Ping timeout: 268 seconds]
tane has quit [Quit: Leaving]
Jesin has joined #ocaml
asymptotically has quit [Quit: Leaving]
zolk3ri has quit [Remote host closed the connection]
iAmDecim has quit [Ping timeout: 252 seconds]
iAmDecim has joined #ocaml
jjmeyer0 has joined #ocaml