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
aubian has quit [Ping timeout: 252 seconds]
Fardale has quit [Ping timeout: 264 seconds]
quipa_ has joined #ocaml
jao has quit [Ping timeout: 252 seconds]
quipa has quit [Ping timeout: 272 seconds]
carlosdagos has joined #ocaml
aubian has joined #ocaml
Fardale has joined #ocaml
ziyourenxiang has joined #ocaml
wilfredh has quit [Quit: Connection closed for inactivity]
sspreitz9 has joined #ocaml
sspreitz9 has quit [Remote host closed the connection]
Jesin has joined #ocaml
Jesin has quit [Quit: Leaving]
zlsyx has joined #ocaml
zlsyx_ has joined #ocaml
zlsyx has quit [Ping timeout: 272 seconds]
zlsyx_ has quit [Quit: Leaving...]
ygrek__ has quit [Remote host closed the connection]
ygrek__ has joined #ocaml
warriors has joined #ocaml
ygrek__ has quit [Ping timeout: 272 seconds]
MadcapJake has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
hunboy5 has joined #ocaml
hunboy5 has quit [Remote host closed the connection]
maximjaffe has joined #ocaml
quipa_ has quit [Ping timeout: 268 seconds]
Jesin has joined #ocaml
tormen_ has joined #ocaml
tormen has quit [Ping timeout: 272 seconds]
maximjaffe has quit [Ping timeout: 240 seconds]
cthuluh has quit [Ping timeout: 245 seconds]
cthuluh has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
dsp has joined #ocaml
<dsp> hey ocaml ppl. can you explain smth to me because i feel like an utter moron? i am trying lear ocaml and define just an iterative fibonacci. so i have a let fibiter a b n = if n > smth then a else fibiter b a+b n+1 in...
<dsp> i keep getting a This expression has type 'a -> 'b but an expression of type int was expected. is it complaining because my return type from fibiter is ambiguous?
<dsp> sorry i'm a schemer trying to start with ocaml
metreo has left #ocaml [#ocaml]
<warriors> you probably need let rec fitbiter
<warriors> you need to declare a function recursive in ocaml
<warriors> or ml langs in general
<warriors> ocaml have shadowing
<warriors> so without recursive declaration the system will try to look first for a previous definition of fibiter
<warriors> or so i think
<warriors> i am not an ocaml expert
<warriors> but ocaml is the best
<dsp> 1b1i finally did it like that... i don't know how valid ocaml this is
<dsp> let fib1 n =
<dsp> in
<dsp> | (a,b,c) when c > n -> a
<dsp> let rec fibiter = function
<dsp> | (a, b, c) -> fibiter(b,a+b,c+1)
<dsp> fibiter(1,1,0);;
<dsp> this looks quite elegant so i think it's ok for a first approach. but here is my question now... is the tupling of the arguments necessary here? or could i have smth like | a b c when c > n -> and call like fibiter b a+b c+1 ?
<dsp> i tried it and failed initially but it could also be a pebkac.
<warriors> just use an if statement then
<warriors> if c > n then a else fibitier b (a+b) (c+1)
<dsp> so that's how was failing originally, check this out
<dsp> let fib2 n =
<dsp> let rec fibiter a b c =
<dsp> if c > n then a else fibiter b a+b c+1
<dsp> in
<dsp> fibiter(1,1,0);;
<dsp> this fails with type 'a -> 'b etc...
<warriors> that last fitibier should be fibiter 1 1 0
<warriors> dont tuple it
<dsp> oh sorry yes
<warriors> does it work now
<dsp> no :)
<warriors> bleh
<dsp> here warriors , since you share my pain this is exactly what i have been trying
<dsp> thanks for your time btw.
<warriors> this seem to work
<warriors> fib2 9 = 89 ???
<warriors> is this the expected answer
<dsp> yes the 9th fibonacci is 89
<warriors> maybe yours failed because you didnt bracket the params
<dsp> o m g
<dsp> it's the parenthesis
<dsp> wat?
<warriors> so fibiter b a+b c+1 was treated (fibiter b a+b c)+1
<warriors> or something
<warriors> probably
<dsp> it is the difference of calling fibi b (a+b) (c+1) instead of fibi b a+b c+1 ....
<dsp> ocaml reader vs dsp : 20-1
<dsp> thanks again warriors
<warriors> de rien
<warriors> you are welcome
fds has quit [Ping timeout: 244 seconds]
MadcapJake has quit [Quit: MadcapJake]
bartholin has joined #ocaml
sagotch has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
kalio has quit [Ping timeout: 246 seconds]
kalio has joined #ocaml
orbifx1 has joined #ocaml
pierpal has quit [Ping timeout: 244 seconds]
sagotch has quit [Ping timeout: 260 seconds]
pierpal has joined #ocaml
fraxamo has joined #ocaml
warriors has quit [Quit: Connection closed for inactivity]
sagotch has joined #ocaml
kakadu has joined #ocaml
silenc3r has joined #ocaml
groovy2shoes has joined #ocaml
sagotch has quit [Ping timeout: 260 seconds]
jao has joined #ocaml
ygrek__ has joined #ocaml
mfp has joined #ocaml
sagotch has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
jjmeyer0 has joined #ocaml
asymptotically has joined #ocaml
sagotch has quit [Ping timeout: 260 seconds]
sagotch has joined #ocaml
ygrek__ has quit [Ping timeout: 245 seconds]
pierpal has quit [Read error: Connection reset by peer]
Guest54709 has joined #ocaml
carlosdagos has quit [Quit: Connection closed for inactivity]
orbifx1 has quit [Ping timeout: 268 seconds]
ggole has joined #ocaml
jjmeyer0 has quit [Ping timeout: 264 seconds]
ski has quit [Ping timeout: 264 seconds]
pierpal has joined #ocaml
Guest54709 has quit [Remote host closed the connection]
silenc3r has quit [Remote host closed the connection]
asymptotically has quit [Remote host closed the connection]
asymptotically has joined #ocaml
asymptotically has quit [Remote host closed the connection]
asymptotically has joined #ocaml
asymptotically has quit [Remote host closed the connection]
asymptotically has joined #ocaml
asymptotically has quit [Remote host closed the connection]
asymptotically has joined #ocaml
sagotch has quit [Quit: Leaving.]
weird_error has joined #ocaml
EvanR6 has joined #ocaml
EvanR6 has quit [Remote host closed the connection]
zolk3ri has joined #ocaml
asymptotically has quit [Remote host closed the connection]
asymptotically has joined #ocaml
jbrown has quit [Ping timeout: 252 seconds]
metreo has joined #ocaml
leah2 has quit [Ping timeout: 268 seconds]
poemve has joined #ocaml
poemve has quit [Remote host closed the connection]
jao has quit [Read error: Connection reset by peer]
jao has joined #ocaml
fds has joined #ocaml
leah2 has joined #ocaml
jao has quit [Read error: Connection reset by peer]
jao has joined #ocaml
jao has quit [Read error: Connection reset by peer]
jao has joined #ocaml
jao has quit [Disconnected by services]
jao has joined #ocaml
adr has joined #ocaml
ski has joined #ocaml
zolk3ri has quit [Quit: Lost terminal]
MadcapJake has joined #ocaml
tane has joined #ocaml
jbrown has joined #ocaml
jjmeyer0 has joined #ocaml
ziyourenxiang has quit [Ping timeout: 252 seconds]
adr has quit [Ping timeout: 245 seconds]
jjmeyer0 has quit [Ping timeout: 244 seconds]
jnavila has joined #ocaml
ggole has quit [Quit: ggole]
jnavila has quit [Ping timeout: 268 seconds]
leah2 has quit [Ping timeout: 264 seconds]
leah2 has joined #ocaml
warriors has joined #ocaml
Guest34352 has joined #ocaml
adr has joined #ocaml
Guest34352 has quit [Remote host closed the connection]
adr has quit [Client Quit]
Haudegen has joined #ocaml
pierpal has quit [Remote host closed the connection]
pierpal has joined #ocaml
jjmeyer0_ has joined #ocaml
jnavila has joined #ocaml
tane has quit [Quit: Leaving]
fraxamo has quit [Quit: Leaving]
jjmeyer0_ has quit [Ping timeout: 264 seconds]
Jesin has quit [Ping timeout: 276 seconds]
jbrown has quit [Ping timeout: 252 seconds]
jnavila has quit [Remote host closed the connection]
bartholin has quit [Remote host closed the connection]
Haudegen has quit [Remote host closed the connection]
orbifx1 has joined #ocaml
jjmeyer0_ has joined #ocaml
kakadu has quit [Remote host closed the connection]
orbifx1 has quit [Ping timeout: 245 seconds]
jjmeyer0_ has quit []