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
themsay has joined #ocaml
jao has quit [Remote host closed the connection]
zolk3ri has quit [Quit: Lost terminal]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jao has joined #ocaml
jaar has quit [Ping timeout: 252 seconds]
orbifx has quit [Ping timeout: 244 seconds]
themsay has quit [Ping timeout: 246 seconds]
pierpal has quit [Ping timeout: 250 seconds]
jmiven has quit [Quit: co'o]
jmiven has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
jao has quit [Remote host closed the connection]
objmagic has joined #ocaml
objmagic has quit [Client Quit]
jao has joined #ocaml
themsay has joined #ocaml
kvda has joined #ocaml
objmagic has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
tormen_ has joined #ocaml
tormen has quit [Ping timeout: 244 seconds]
jao has quit [Remote host closed the connection]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jao has joined #ocaml
objmagic_ has joined #ocaml
objmagic has quit [Ping timeout: 250 seconds]
objmagic_ has quit [Ping timeout: 244 seconds]
objmagic has joined #ocaml
nullifidian_ has joined #ocaml
nullifidian has quit [Ping timeout: 268 seconds]
ygrek has quit [Ping timeout: 250 seconds]
esum has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
jao has quit [Ping timeout: 250 seconds]
wickedshell has quit [Ping timeout: 250 seconds]
wickedshell has joined #ocaml
kalio has quit [Ping timeout: 268 seconds]
kalio has joined #ocaml
jaar has joined #ocaml
sagotch has joined #ocaml
sgnb has joined #ocaml
Haudegen has joined #ocaml
<ruffy_> I wanted to use a standard List function of Haskell in OCaml. I simply copied the source code and adapted the syntax, but I don't know why this is not working. Can anybody help me?
<ruffy_> let rec permutations xs0 =
<ruffy_> let rec perms xs is = match xs with
<ruffy_> | [] -> []
<ruffy_> | (t::ts) ->
<ruffy_> let rec interleave' f xs' r = match xs' with
<ruffy_> | [] -> (ts, r)
<ruffy_> | (y::ys) ->
<ruffy_> let (us,zs) =
<ruffy_> interleave' (f @.@ (cons y)) ys r
<ruffy_> in
<ruffy_> (y::us, f (t::y::us) :: zs)
<ruffy_> in
<ruffy_> let interleave xs r =
<ruffy_> let (_,zs) =
<ruffy_> interleave' id xs r
<ruffy_> in
<ruffy_> zs
<ruffy_> in
<ruffy_> foldr interleave (perms ts (t::is)) (permutations is)
<ruffy_> in
<ruffy_> xs0 :: perms xs0 []
<ruffy_> ;;y
<ruffy_> permutations [1;2] gives [[1; 2]; [1; 1; 2]; []]
<ruffy_> @.@ is function composition, and foldr an alias to fold_right
<ruffy_> the desired result for [1;2] would be [[1;2];[2;1]]
themsay has quit [Ping timeout: 246 seconds]
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
nullifidian_ is now known as nullifidian
jaar has quit [Ping timeout: 252 seconds]
<octachron> ruffy_, you should link to a copy-pasting site or from sketch.sh to make your code more readable
<vsiles> ruffy_: can you paste the original haskell code too ?
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
<ruffy_> octachron: OCaml code https://pastebin.com/ywEc80CW
<ruffy_> vsiles: Haskell code https://pastebin.com/4Bw7e12B
<vsiles> got it
<vsiles> ruffy_: foldr in Haskell and List.fold_right in ocaml don
<vsiles> 't have the same signature
<vsiles> the last two arguments must be switched
<vsiles> foldr :: (a -> b -> b) -> b -> [a] -> b in Haskell vs (a -> b -> b) -> a list -> b -> b in ocaml
kjak has quit [Ping timeout: 268 seconds]
<ruffy_> vsiles: thx, that was my mistake.
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
jaar has joined #ocaml
<notnotdan> yeah the one in ocaml stdlib is not very curry-able
<notnotdan> there is a version in JaneStreet's library which has named arguments
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
mfp has joined #ocaml
Haudegen has quit [Read error: Connection reset by peer]
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
zolk3ri has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
sagotch has quit [Quit: Leaving.]
slamzy has joined #ocaml
sgnb has quit [Remote host closed the connection]
sgnb has joined #ocaml
jao has joined #ocaml
sgnb has quit [Remote host closed the connection]
sspi has quit [Ping timeout: 252 seconds]
sspi has joined #ocaml
zolk3ri has quit [Ping timeout: 256 seconds]
KeyJoo has joined #ocaml
sagotch has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 245 seconds]
objmagic has quit [Ping timeout: 245 seconds]
spew has joined #ocaml
pierpal has joined #ocaml
zolk3ri has joined #ocaml
slamzy has quit [Quit: Leaving]
objmagic has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
al-damiri has joined #ocaml
slamzy has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
zolk3ri has joined #ocaml
slamzy has quit [Quit: Leaving]
KeyJoo has quit [Quit: KeyJoo]
zolk3ri_ has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
zolk3ri_ is now known as zolk3ri
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
jonatan has joined #ocaml
jao has quit [Ping timeout: 244 seconds]
ziyourenxiang has quit [Ping timeout: 240 seconds]
bartholin has joined #ocaml
FreeBirdLjj has joined #ocaml
gareppa has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
waleee has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
FreeBirdLjj has joined #ocaml
gareppa has quit [Read error: Connection reset by peer]
sagotch has quit [Quit: Leaving.]
jao has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
jnavila has joined #ocaml
jnavila has quit [Ping timeout: 252 seconds]
marsam has joined #ocaml
<Leonidas> notnotdan: that particular bit is also in the regular stdlib: https://caml.inria.fr/pub/docs/manual-ocaml/libref/ListLabels.html
jnavila has joined #ocaml
kakadu_ has joined #ocaml
kjak has joined #ocaml
zolk3ri has quit [Ping timeout: 256 seconds]
marsam has quit [Ping timeout: 252 seconds]
jaar has quit [Ping timeout: 252 seconds]
nullifidian has quit [Read error: Connection reset by peer]
nullifidian has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
themsay has joined #ocaml
Haudegen has joined #ocaml
objmagic has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
objmagic has joined #ocaml
themsay has quit [Ping timeout: 250 seconds]
jnavila has joined #ocaml
bartholin has quit [Remote host closed the connection]
zolk3ri has joined #ocaml
ygrek has joined #ocaml
slamzy has joined #ocaml
pierpal has quit [Ping timeout: 240 seconds]
al-damiri has quit [Quit: Connection closed for inactivity]
mengu has joined #ocaml
kvda has joined #ocaml
Haudegen has quit [Ping timeout: 250 seconds]
Haudegen has joined #ocaml
themsay has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
mengu has quit [Remote host closed the connection]
waleee has quit [Quit: WeeChat 2.3]
objmagic has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
objmagic has joined #ocaml
orbifx has joined #ocaml
objmagic has quit [Client Quit]
objmagic has joined #ocaml
nullifidian_ has joined #ocaml
slamzy has quit [Ping timeout: 256 seconds]
nullifidian has quit [Ping timeout: 250 seconds]
jnavila has quit [Remote host closed the connection]
sonologico has joined #ocaml
marsam has joined #ocaml
marsam has quit [Remote host closed the connection]
marsam has joined #ocaml
objmagic has quit [Read error: Connection reset by peer]
objmagic has joined #ocaml
mengu has joined #ocaml
steenuil has quit [Remote host closed the connection]
steenuil has joined #ocaml
mengu has quit [Ping timeout: 244 seconds]
jao has quit [Remote host closed the connection]
objmagic has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mengu has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
zolk3ri has quit [Ping timeout: 256 seconds]
jao has joined #ocaml
anmonteiro has joined #ocaml
orbifx has quit [Ping timeout: 268 seconds]
zolk3ri has joined #ocaml
kfor has joined #ocaml
kfor has quit [Ping timeout: 256 seconds]
kakadu_ has quit [Remote host closed the connection]
Haudegen has quit [Remote host closed the connection]
objmagic has joined #ocaml
objmagic has quit [Ping timeout: 245 seconds]
objmagic has joined #ocaml