<cpdean>
there's a homework assignment to write a function that checks if two values are "valid", and then you use it to write a function that will search for the correct pair of numbers in a range
<cpdean>
this feels like it should be a pretty straight-forward brute force problem but when i write a recursive solution it never returns, and i'm not sure how to debug it...
<cpdean>
#trace shows me it evaluates several intermediate values instantly and then it just hangs for a few minutes, then spits out a couple more function evaluations then keeps waiting
<Drup>
could you link to the precise exercise and show your current code (use a pastebin) ?
<cpdean>
Drup: if you can't access the problem description i can paste that in as well
<Drup>
I can access :p
<cpdean>
nice!
<cpdean>
i don't want to use a while or forloop because i feel like that'd be kind of cheating -- and as i'm following the course a couple weeks late i can see they do things with 'impure' ocaml features later on
<cpdean>
so i feel like it wasn't intended to be solved with imperative techniques
dmi3y has quit [Quit: dmi3y]
o77 has joined #ocaml
<Drup>
well, you don't really have to enumerate everything
<Drup>
for a given grand son age, you only ever have to try the quadruple, and then move on
<cpdean>
Drup: that's true... but in any case shouldn't an answer come back pretty quick? testing on the range (99, 10) should come back pretty fast, it shouldn't be more than 1k comparisons right?
<o77>
is there any tool to help "debug" a recursive function step by step?
kevinch has joined #ocaml
<Drup>
cpdean: your implementation is quite exponential ...
<cpdean>
oh i guess "left" and "right" will contain a lot of dupes...
<Drup>
exactly
<cpdean>
bummer... i was hoping i could just do this in the most naiive way and have it finish in under 10 seconds
zpe has quit [Remote host closed the connection]
<Drup>
the correct implementation is actually simpler/shorter than your version, though ;)
zpe has joined #ocaml
<cpdean>
just because an implementation is simple or short, doesn't mean it was easy to get there, Drup
<cpdean>
;)
<Drup>
o77: in the toplevel, you can use the #trace directive
kevinch has quit [Quit: Computer has gone to sleep.]
zpe has quit [Ping timeout: 256 seconds]
<cpdean>
o77: and if you want more information printed out, rewrite your sublists function with type annotations so that the trace directive prints out the intermediate lists of numbers: https://ocaml.org/learn/tutorials/debug.html
<cpdean>
otherwise you're going to get a lot of : sublists --> [[]; [<poly>]; [<poly>]; [<poly>; <poly>]]
<cpdean>
Drup: thanks for the advice, i'll try re-writing this and see how it goes
brunoro has joined #ocaml
brunoro has quit [Ping timeout: 260 seconds]
cpdean has quit [Ping timeout: 250 seconds]
wxfdglm_ has joined #ocaml
wxfdglm has quit [Ping timeout: 260 seconds]
Orion3k has quit [Remote host closed the connection]
tormen has joined #ocaml
xieyuheng has joined #ocaml
boxed has joined #ocaml
kevinch has joined #ocaml
<boxed>
Can I enumerate a sum type? or make a function that parses a sum type from some input and guarantee that all outputs are present in the parser (ie the reverse of a to string conversion with a case)
brunoro has joined #ocaml
kevinch has quit [Client Quit]
<Drup>
ppx_deriving can do that
brunoro has quit [Ping timeout: 256 seconds]
cpdean has joined #ocaml
kevinch has joined #ocaml
jnavila has quit [Ping timeout: 268 seconds]
<o77>
Drup: and cpdean: thanks for the tips!
sillyotter has joined #ocaml
<o77>
Another question: how to type annotate the input parameter of a `let namefunc = function`? Do I need to convert it to `let namefunc nameparam = match`?
<o77>
i.e. `let namefunc (nameparam : type) = match`
<Drup>
let namefunc : input -> output = function ...
<o77>
the '-> output' type annotation is optional, right?
<Drup>
No, but you can use "_" to mean "any type"
jnavila has joined #ocaml
<o77>
Thanks once again Drup! It's Sunday (at least in my meridian) you should charge extra charge for the support! :-)
slash^ has quit [Read error: Connection reset by peer]
kevinch has quit [Quit: Computer has gone to sleep.]
kakadu has joined #ocaml
mayathecat has quit [Remote host closed the connection]
Heasummn has joined #ocaml
wxfdglm_ has quit [Ping timeout: 252 seconds]
xieyuheng has quit [Quit: ChatZilla 0.9.92 [Firefox 49.0.2/20161021084537]]
Heasummn has quit [Read error: Connection reset by peer]
jnavila has joined #ocaml
dmi3y has quit [Quit: dmi3y]
brunoro has joined #ocaml
freusque has joined #ocaml
brunoro has quit [Ping timeout: 250 seconds]
o77 has quit [Quit: Page closed]
mayathecat has joined #ocaml
mayathecat has quit [Remote host closed the connection]
AlexDenisov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
freusque has quit [Quit: WeeChat 1.4]
Algebr has quit [Ping timeout: 250 seconds]
jnavila has quit [Ping timeout: 260 seconds]
Heasummn has joined #ocaml
zaltekk has quit [Ping timeout: 256 seconds]
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 252 seconds]
wolfcore has quit [Read error: Connection reset by peer]
<cpdean>
i'm having total writers block trying to figure out how to do a 2 dimensional search without a loop
<cpdean>
am i going to have to pass around a bunch of extra state just to keep track of where i am in the search to keep this implementation recursive? that seems so ugly
<cpdean>
claims there should be one in (84, 12) and (99, 10) but my impl spits out (-1, -1) for them
jnavila has quit [Client Quit]
<Drup>
one line 17, you don't want to test with f, that's just the upper limit. You should test with 4*s directly (since you checked that it's relevant in line 16)
<petroav>
Hi all! Is it possible to browse library source code in Vim using Merlin?
<petroav>
I've added "PKG core" to my .melin but when I try to navigate to the definition of the core module Merlin tells me that the corresponding ML file can't be found. Do I have to add the source paths to the Core module to my .merlin?