Riastradh has quit [Nick collision from services.]
Riastrad1 is now known as Riastradh
<Demitar>
phubuh, neat, although a module L = ... statement can get almost the same effect I guess.
<atom-z>
is it possible to access List.filter in an object oritented way i.e. listObj.filter(function)?
* Demitar
shudders as the box starts swapping (24M ram simply isn't enough).
<Riastradh>
atom-z, no, unless you write a list class that supports a filter method, but that would be kind of silly.
<mattam>
aren't statements like 'let _ = dosmthg' always evaluated at program startup (before statements in modules which are next on the command line) ?
<mattam>
i have a case where it doesn't work
<atom-z>
ok
<atom-z>
thanks for the help
<mattam>
this is really anoying :(
<Demitar>
mattam, afaik any toplevel commands should be run in the module linking order. (That is: yes.)
<mellum>
mattam: maybe you have a typo? try let () = ... to see whether you didn't accidentally define a function
<mattam>
mellum: ?
<mellum>
mattam: !
<Demitar>
mellum: "All hail ignore"? ;-)
<mattam>
i don't understand what you mean mellum
<Riastradh>
mattam, if the RHS is a function, then it won't get evaluated.
<Demitar>
mattam: "let _ = List.map (fun x -> x ^ x)" is valid but doesn't do anything.
<Riastradh>
let () = ... won't work for that case, anyways, because List.map returns a list, not unit.
<mattam>
:) no, it is not that sort of errors
<atom-z>
hmm
<atom-z>
how do i write a function that takes a' and returns a bool (for filter)?
<mattam>
i have an x = ref [] in one module and i do 'let _ = Mod.x := [foo; bar]' in the other one
<atom-z>
i want it to see if the element is positive, or now
<atom-z>
err
<atom-z>
*not
<Smerdyakov>
mattam, have you specified the type of x somewhere for the first module?
<mattam>
Smerdyakov: yep, in the mli and the ml
<mattam>
i tried doing the same with three files and it works (let x = ref [] in init.ml let _ = x := [1; 2] in snd.ml and let _ = {print x list} in main.ml. Compiled with ocamlc init.ml snd.ml main.ml)
<mattam>
i'm absolutely clueless
<atom-z>
i cant seem to find an example of how to use filter
<atom-z>
iirc 'a means anything
<Riastradh>
atom-z, write something in Python that would filter out all the element of 'list' that are greater than 5.
<Maddas>
atom-z: which part don't you understand?
<mellum>
atom-z: List.filter (fun x -> x > 17) [6; 23; 666; 0]
<atom-z>
def positive(n):
<Maddas>
your function doesn't *need* to take 'a
<atom-z>
return n > 5
<atom-z>
filter(n,list)
<Riastradh>
Does that actually _work_, now?
<atom-z>
Riastradh: the python code?
<Riastradh>
Yes.
<Riastradh>
It doesn't look to me as though it will.
systems has quit [Read error: 60 (Operation timed out)]
<Riastradh>
I think you probably meant 'filter(positive, list)'.
<atom-z>
yes it does
<Riastradh>
Even then, it's rather silly to define positive. Are you not aware of lambda?
<atom-z>
oh yeah
<atom-z>
that is a small typo
<atom-z>
yeah i know about lambda
<Riastradh>
OCaml's lambda is 'fun' or 'function.'
<atom-z>
ok
<atom-z>
mellum: that works, i was calling filter like List.filter(f,l)
<Maddas>
List.filter doesn't take a tuple :)
brwill_zzz is now known as brwill
<atom-z>
so that doesnt call it with the parameters f,l it calls it with one parameter, a tuple (f,l)?
<mellum>
Yes. You cannot call a function with two parameters, all functions have only one.
<atom-z>
ah i see
<atom-z>
thanks
<Maddas>
atom-z: your call would have called it with a tuple, yes
<mattam>
apparently the module that redefines the variable isn't initialized. A print_endline "initializing";; doesn't work either
<mattam>
duh, it's in my.cma, but if i add it like this: ocamlc my.cma redefiner.cmo main.ml it works ??? It should work without that and there should be errors for redefinitions also. Did i overlooked something ?
<mattam>
-linkall !
<Demitar>
mattam, three minor suggestions, 1. try without let _ = 2. try without .mli 3. try without using a lib (compile all the .ml files and link in one run). This is mostly shotgun debugging of course.
<mattam>
i works now Demitar, -linkall was missing
<mattam>
i can't think of why the default is not to link all object files
* Demitar
read the manual and coincides that it makes sense.
<mattam>
lost 45 minutes on that
<Demitar>
mattam, efficiency?
<mattam>
you mean space efficiency ?
* Demitar
notes that he should get back to his programming.
<Demitar>
mattam, something like that.
<mattam>
well, i do not find it sensible to have an optimization that changes the semantics of linking like that as a default. Maybe i'm getting a bit subjective on the issue though :p
* mattam
back to code
<Demitar>
Well, C/C++ does the same thing.
<Demitar>
(That is many *compilers* naturally.)
__DL__ has quit [leguin.freenode.net irc.freenode.net]
Smerdyakov has quit [leguin.freenode.net irc.freenode.net]
brwill has quit [leguin.freenode.net irc.freenode.net]
det has quit [leguin.freenode.net irc.freenode.net]
__DL__ has joined #ocaml
brwill has joined #ocaml
Smerdyakov has joined #ocaml
det has joined #ocaml
Riastradh has quit [Read error: 54 (Connection reset by peer)]
Riastradh has joined #ocaml
Riastradh has quit [Nick collision from services.]
Riastradh has joined #ocaml
polin8 has quit [Read error: 104 (Connection reset by peer)]
polin8 has joined #ocaml
systems has joined #ocaml
Rhamphoryncus has left #ocaml []
clog has joined #ocaml
Riastrad1 has joined #ocaml
Riastradh has quit [Nick collision from services.]
Riastrad1 is now known as Riastradh
__DL__ has quit [Remote closed the connection]
Riastrad1 has joined #ocaml
Riastradh has quit [Nick collision from services.]
Riastrad1 is now known as Riastradh
clam has joined #ocaml
<mattam>
Demitar: is it ? :)
polin8 has quit ["Now _that's_ a good cup of coffee."]
<Demitar>
mattam: Eh? (Was that perhaps a pun on my misspeling I didn't get? ;-)
lus|wazze has joined #ocaml
lus|wazze has quit [Read error: 104 (Connection reset by peer)]