00:06
mrvn_ has quit [Read error: 110 (Connection timed out)]
00:08
matkor has quit [Remote closed the connection]
01:37
<
mellum >
Hmm, I want a funktion that takes two 'a list lists, and returns a list with all concatenations from them. Any suggestions on how to do that elegantly?
01:37
<
whee >
all possible combinations?
01:38
<
mellum >
Actually, they need to be sorted too, but that's for another function to do I guess
01:38
<
whee >
there's a relatively easy way, but I can't remember it :)
01:44
<
whee >
you cnan probably do it with a few fold_lefts
01:44
<
whee >
or a couple, even
01:44
<
mellum >
Hm, I was trying List.map
01:45
<
whee >
it's really easy to do in a language with list comprehensions, which ocaml doesn't have :\
01:45
<
mellum >
Well, I already changed language once :)
01:47
<
mellum >
Hm, I think it gets easier if I pass the result around
01:47
<
mellum >
not quite as pretty, though
01:49
<
whee >
the haskell version with list comprehensions is something like combinations (x:xs) = [(y:ys) | y <-x, ys <- combinations xs]
01:49
<
whee >
you could try translating that :)
01:49
<
whee >
it probably does end up turning into a few fold_lefts
01:52
<
whee >
maybe a map thrown in there
01:52
<
whee >
I don't know :)
01:52
<
whee >
it'd be nice if they were added to the language, heh
01:53
<
mellum >
Well, I can do it with using @'s, but I would rather have it tail recursive...
01:53
<
mellum >
Oh well, this part is going to change later anyway, so I give up for now
01:53
<
whee >
you could prepend to the list instead
01:53
<
whee >
then reverse at the end if order really matters
01:56
<
mellum >
I don't see how
01:56
<
mellum >
Currently I got
01:56
<
mellum >
let rec concat ll1 ll2 =
01:56
<
mellum >
match ll1 with
01:56
<
mellum >
| l1 :: l1s ->
01:56
<
mellum >
(List.map (fun l -> l1 @ l) ll2) @ concat l1s ll2
02:02
<
whee >
what's the function behind ::? :|
02:04
<
mellum >
(::) of course :)
02:04
<
whee >
that doesn't work
02:05
<
whee >
it's a syntax error; I don't know how else to reference operators
02:05
<
mellum >
Oh, wait, (::) is magic
02:05
<
mellum >
because it can also be used in matchings
02:08
<
whee >
oh, well that didn't work
02:12
<
whee >
I ended up doing the power set I think :)
02:13
<
mellum >
Keep that, might be handy sometimes, too :)
02:24
<
mrvn >
mellum: ever tried val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list ?
02:25
<
mrvn >
or List.rev (List.rev_map2 f a b)
02:25
<
mrvn >
for tail-recursion
02:34
<
mellum >
mrvn: that matches the list pairwise, but I want all possible pairs
02:34
<
mrvn >
mellum: List.fold_leftlet combine l1 l2 =
02:35
<
mrvn >
List.fold_left
02:35
<
mrvn >
(fun res w1 ->
02:35
<
mrvn >
List.fold_left
02:35
<
mrvn >
(fun res w2 -> (w1@w2)::res)
02:35
<
mrvn >
List.rev l;;
02:35
<
mellum >
Hmm, let me try
02:35
<
mrvn >
let l1 = [['0']; ['1']];;
02:35
<
mrvn >
combine l1 l1;;
02:35
<
mrvn >
- : char list list = [['0'; '0']; ['0'; '1']; ['1'; '0']; ['1'; '1']]
02:37
<
mellum >
Looks good
02:38
<
mrvn >
Still an @ in there
02:38
<
mrvn >
But it keeps the sorting if both lists are sorted before
02:39
<
mellum >
the outer sorting is irrelevant. The inner lists need to besorted
02:39
<
mellum >
so I need a special function for the @ anyway
02:40
<
mellum >
mrvn: If you're bored, try writing a function that merges two descendingly sorted lists into an ascendingly sorted one :)
02:40
<
whee >
can't you just reverse both and merge?
02:40
<
mellum >
whee: aw, that's lame
02:41
<
mellum >
although I probably still do it because it's shorter
02:41
<
mrvn >
mellum: just remove the extra List.rev in the code above
02:42
<
mellum >
mrvn: No, it's for the inner lists
02:42
<
mellum >
Hmm, does it matter performance-wise whether I leave off the arguments to l?
02:44
<
mellum >
Yes, the final call of the loop.
02:45
<
mellum >
Oh, never mind.
02:53
<
mrvn >
let rev_wappend (w:'a list) (l:'a list list) =
02:53
<
mrvn >
List.fold_left
02:53
<
mrvn >
(fun l x -> List.map (fun w -> x::w) l)
02:53
<
mrvn >
(List.map List.rev l) w;;
02:53
<
mrvn >
let combine l1 l2 =
02:53
<
mrvn >
List.fold_left
02:53
<
mrvn >
(fun res w1 -> rev_wappend w1 l2@res)
02:53
<
mrvn >
List.rev l;;
02:53
<
mrvn >
let l1 = [['b';'a']; ['d';'c']; ['f';'e']; ['h';'g']];;
02:53
<
mrvn >
let l2 = [['1';'0']; ['3';'2']; ['5';'4']; ['7';'6']];;
02:54
<
mrvn >
combine l1 l2;;
02:54
<
mrvn >
[['a'; 'b'; '6'; '7']; ['a'; 'b'; '4'; '5']; ['a'; 'b'; '2'; '3'];
02:54
<
mrvn >
['a'; 'b'; '0'; '1']; ['c'; 'd'; '6'; '7']; ['c'; 'd'; '4'; '5'];
03:06
__DL__ has joined #ocaml
03:26
Sonarman has joined #ocaml
04:04
Kinners has joined #ocaml
04:11
__DL__ has quit ["Client Exiting"]
04:59
det has joined #ocaml
05:03
jemfinch`` has joined #ocaml
05:04
jemfinch`` is now known as jemfinch
05:11
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
05:17
Kinners has left #ocaml []
05:27
skylan has quit ["bbiab"]
06:14
Sonarman has quit ["Lost terminal"]
06:41
skylan has joined #ocaml
06:47
mattam has joined #ocaml
06:47
skylan has quit [leguin.freenode.net irc.freenode.net]
06:47
mellum has quit [leguin.freenode.net irc.freenode.net]
06:47
rox has quit [leguin.freenode.net irc.freenode.net]
06:47
emu has quit [leguin.freenode.net irc.freenode.net]
06:48
mellum has joined #ocaml
06:48
emu has joined #ocaml
06:48
skylan has joined #ocaml
06:49
rox has joined #ocaml
06:58
lament has joined #ocaml
07:00
Rhaaw has joined #ocaml
08:27
<
Rhaaw >
What's the best place to start learing ocaml ?
08:27
<
lament >
Probably the channel topic.
08:27
<
Rhaaw >
That O'Reilly book ?
08:30
<
Rhaaw >
The thing is, I don't want to start with something as bad for ocaml as Sams teach yourself C++ in...
08:38
<
lament >
i actually meant the ocaml website :)
08:38
lament has quit ["Did you know that God's name is ERIS, and that He is a girl?"]
08:53
gehel has joined #ocaml
08:55
gehel is now known as gl
10:16
TachYon26 has joined #ocaml
10:24
<
emu >
best place to leer at camels would be the middle east i say
10:37
gl has quit ["Lost terminal"]
11:00
det has quit [Remote closed the connection]
11:11
jemfinch has quit [Read error: 104 (Connection reset by peer)]
11:11
jemfinch has joined #ocaml
11:47
foxster has quit [Connection reset by peer]
11:51
xkb has joined #ocaml
11:52
xkb has quit ["Killed by frash (Requested by panasync)"]
11:54
xkb has joined #ocaml
12:13
foxster has joined #ocaml
12:29
Rhaaw has quit [Read error: 110 (Connection timed out)]
12:32
Rhaaw has joined #ocaml
12:37
det has joined #ocaml
12:40
det has quit [Client Quit]
12:41
det has joined #ocaml
12:42
det has quit [Client Quit]
13:11
mellum_ has joined #ocaml
13:14
physarum has joined #ocaml
13:17
mellum has quit [Read error: 110 (Connection timed out)]
13:22
mrvn_ has joined #ocaml
13:26
mrvn has quit [Read error: 60 (Operation timed out)]
13:59
foxster has quit [Read error: 60 (Operation timed out)]
14:03
det has joined #ocaml
14:20
jemfinch has quit [Read error: 54 (Connection reset by peer)]
14:25
det has quit [Remote closed the connection]
14:46
physarum has quit ["Client Exiting"]
15:51
merriam has quit [Excess Flood]
16:02
mattam has quit ["leaving"]
16:19
mrvn has joined #ocaml
16:26
mrvn_ has quit [Read error: 104 (Connection reset by peer)]
16:28
Dalroth has joined #ocaml
16:41
rox has left #ocaml []
16:46
polin8 has joined #ocaml
17:01
steele has joined #ocaml
17:35
esabb has joined #ocaml
18:02
TachYon26 has quit [Remote closed the connection]
18:05
Rhaaw has left #ocaml []
19:05
foxster has joined #ocaml
19:16
mattam has joined #ocaml
19:18
mellum_ is now known as mellum
19:22
matkor has joined #ocaml
19:24
redcrosse has joined #ocaml
20:17
esabb has left #ocaml []
20:26
mattam_ has joined #ocaml
20:34
mattam has quit [Read error: 60 (Operation timed out)]
20:39
matkor has quit ["Client Exiting"]
20:48
gene9 has joined #ocaml
20:48
gene9 has quit [Client Quit]
22:05
Dalroth has quit []
22:27
mrvn has quit [Read error: 110 (Connection timed out)]
22:57
<
whee >
haha, daniel
_did_ decide to completely stop working on camlp4
22:57
<
whee >
what a baby :)
23:27
redcrosse has quit []
23:28
jemfinch has joined #ocaml