malc has quit [Read error: 60 (Operation timed out)]
jedy has joined #ocaml
Tabu-la-Rasa has joined #ocaml
mattam has quit [leguin.freenode.net irc.freenode.net]
Hadaka has quit [leguin.freenode.net irc.freenode.net]
vegai has quit [leguin.freenode.net irc.freenode.net]
mattam has joined #ocaml
Hadaka has joined #ocaml
vegai has joined #ocaml
mattam has quit [Remote closed the connection]
mattam has joined #ocaml
Hadaka has quit [Read error: 104 (Connection reset by peer)]
Naked has joined #ocaml
Naked is now known as Hadaka
jedy has quit ["Bye."]
jedy has joined #ocaml
cgxt has quit []
jedy has quit ["Bye."]
jedy has joined #ocaml
jedy has quit ["Bye."]
jedy has joined #ocaml
jedy has quit ["Bye."]
jedy has joined #ocaml
jedy has quit [Read error: 104 (Connection reset by peer)]
jedy has joined #ocaml
jedy has quit [Remote closed the connection]
jedy has joined #ocaml
jedy has quit [Client Quit]
jedy has joined #ocaml
jedy has quit ["Bye."]
Kinners has left #ocaml []
lus|wazze has joined #ocaml
lus|wazze` has joined #ocaml
lus|wazze has quit [Read error: 110 (Connection timed out)]
two-face has joined #ocaml
<two-face>
hi
lus|wazze` is now known as lus|wazze
__DL__ has joined #ocaml
lus|wazze has quit ["The Ogre philosopher Gnerdel believed the purpose of life was to live as high on the food chain as possible. She refused to e]
buggs|afk is now known as buggs
systems has joined #ocaml
systems has quit ["Client Exiting"]
lus|wazze has joined #ocaml
lus|wazze has quit [Client Quit]
lus|wazze has joined #ocaml
Guest38071 has joined #ocaml
<Guest38071>
@find "java"
<Guest38071>
find "java"
lus|wazze has quit [Client Quit]
<Maddas>
ugh?
<two-face>
java! hype!
Guest38071 has quit []
lus|wazze has joined #ocaml
buggs|afk has joined #ocaml
buggs has quit [Read error: 110 (Connection timed out)]
lus|wazze` has joined #ocaml
lus|wazze has quit [Read error: 60 (Operation timed out)]
malc has joined #ocaml
<mellum>
I have a boolean function f, and I want to know whether any of the calls (f 0), (f 1), ... (f n) yields true. Does anybody have an idea how to write this nicely in Ocaml? Without let rec loop = blah...
<malc>
Array.init n (fun i -> f i)
<malc>
Array.init n f would suffice actually
<mellum>
Nah, creating a temporary array is just ugly
<Maddas>
Hm, checking a range of function calls without looping or using an array?
<mellum>
Maddas: Well, I can't think of anything either, that's why I ask :)
<Maddas>
:)
lus|wazze` is now known as lus|wazze
lus|wazze` has joined #ocaml
<async>
mellum: you could use fold_right
<async>
nvm, that reqires a temp. list
<Smerdyakov>
I think the appropriate thing to do is create a function from scratch to do this, and reuse it when you encounter the same situation again.
lus|wazze has quit [Read error: 110 (Connection timed out)]
<phubuh>
let range i j = [i .. j] (* not valid ocaml *);; let up_to = range 0;; let any = List.fold_left (or);; any (List.map f (up_to n))
<Smerdyakov>
That uses intermediate lists, which is easy to avoid.
<phubuh>
it's easier not to avoid them.
two-face has quit ["Client exiting"]
malc has quit ["no reason"]
<Smerdyakov>
let rec intAny f n = n > 0 && (f (n-1) || intAll f (n-1))
<Smerdyakov>
s/intAll/intAny
<Smerdyakov>
And there you have it. Less code then you used, and more runtime efficient.
<phubuh>
lazy evaluation would be nice in this situation :-)
<Smerdyakov>
Hardly.
<Smerdyakov>
It lets you write more code to do the same thing. :P
<phubuh>
intAny f n = or $ map f [0 .. n] :P
<Smerdyakov>
But don'
<Smerdyakov>
t you see that it's not lazy evaluation buying you anything?
<Smerdyakov>
It's the pre-existence f [..]
<Smerdyakov>
Which is only slightly more complicated than intAny to begin with.
<Smerdyakov>
er, less
<phubuh>
that adds a bit of clarity as well, but using or with map is clearer than explicit recursion, at least to my eyes.
<Smerdyakov>
Who cares? It's one line of primitive recursion! There's no significant understanding overhead in any case!
<phubuh>
certainly, but it'd still be pretty nice :-)
<mellum>
Smerdyakov: thanks, that looks nicer than what I had
lus|wazze` has quit ["The Ogre philosopher Gnerdel believed the purpose of life was to live as high on the food chain as possible. She refused to e]
<vect>
ls
<phubuh>
.
<phubuh>
..
<vect>
:)
Smerdyakov has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
Demitar has joined #ocaml
Demitar has quit [Client Quit]
<moira>
..
lus|wazze has joined #ocaml
lus|wazze has quit [Client Quit]
lus|wazze has joined #ocaml
Xcalibor has joined #ocaml
arty has joined #ocaml
arty has left #ocaml []
buggs|afk is now known as buggs
systems has joined #ocaml
systems has quit [Read error: 60 (Operation timed out)]
lus|wazze has quit ["The Ogre philosopher Gnerdel believed the purpose of life was to live as high on the food chain as possible. She refused to e]
<Maddas>
hm
<Maddas>
There is no builtin Array/List shuffle function, is there?
<Maddas>
I'll just implement a fisher yates shuffle then
karryall has quit [Remote closed the connection]
reltuk has quit [SendQ exceeded]
reltuk has joined #ocaml
polin8 has quit [Read error: 60 (Operation timed out)]
two-face has joined #ocaml
two-face has quit ["Client exiting"]
malc has joined #ocaml
buggs is now known as buggs|afk
rox has joined #ocaml
Smerdyakov has quit [leguin.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
Smerdyakov has quit [leguin.freenode.net irc.freenode.net]