ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
UziMonkey has quit [":q"]
<sethk>
in general it does
pango_ has quit [Read error: 60 (Operation timed out)]
y6cmE has joined #ocaml
threeve has joined #ocaml
pango has joined #ocaml
<aegray>
can someone look at this and maybe give me insight into what i'm doing wrong? http://pastebin.com/378414
y6cmE has quit [Read error: 110 (Connection timed out)]
<beschmi>
the code seems to be ok and it compiles here
<aegray>
the mapLabTree is supposed to apply a function to all nodes of a tree designated by LTreeNode( 'a, [ (* list of nodes *)])
<aegray>
but if i try to apply it with any function, it fails
<aegray>
i'm trying to implement it with something like:
<aegray>
foldLabTree (fun x y -> ((x, "a"), y)) [] (somefunction) ltree;;
<aegray>
so every nodes label gets changed from x to (x, "a")
<aegray>
but what would somefunction need to be to accomplish that?
<aegray>
ah nm got it
<beschmi>
you want: mapLTree : ('a -> 'b) -> 'a labeled_tree -> 'b labeled_tree
<aegray>
thnx
<beschmi>
np, seems like you've been faster ;)
threeve has quit []
ski has quit [Read error: 110 (Connection timed out)]
_fab has joined #ocaml
ski has joined #ocaml
Skal has joined #ocaml
maayhme has quit ["Leaving"]
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
pango has quit [Remote closed the connection]
pango has joined #ocaml
ppsmimou has joined #ocaml
vezenchio has joined #ocaml
Revision17 has joined #ocaml
revision17_ has quit [Read error: 110 (Connection timed out)]
Submarine has joined #ocaml
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
_fab has quit [Remote closed the connection]
Submarine has quit ["Leaving"]
menace has joined #ocaml
ski has quit [Read error: 104 (Connection reset by peer)]
ChipsterOne has joined #ocaml
mauke has joined #ocaml
__DL__ has joined #ocaml
threeve has joined #ocaml
Snark has joined #ocaml
mauke has quit [Read error: 104 (Connection reset by peer)]
mauke has joined #ocaml
mikeX has joined #ocaml
shirogane has joined #ocaml
ChipsterOne has quit []
Submarine has joined #ocaml
mikeX has quit ["Leaving"]
shirogane has quit [Read error: 104 (Connection reset by peer)]
Snark has quit ["Leaving"]
ppsmimou has quit ["Leaving"]
Schmurtz has joined #ocaml
smimou has joined #ocaml
<dylan>
hmm, it would seem a recursive directory crawling function should slurp the contents of each dir, rather than leaving the dir_handle open.
<dylan>
At least, if you have more sub directories than the maximum number of open file descriptors...
<pango>
on the other hand, some directories may be very large...
<dylan>
True.
<dylan>
Is it safe to assume tail call elimination doesn't somehow magically work in a try ... with construct?
<pango>
it doesn't.
<dylan>
Makes sense.
<dylan>
Could someone tell me if readdir_all (line 10) on http://pastebin.com/378849 is tail recurisve? I assume it is. :)
<dylan>
Or better, a compiler option that tells me the same? :)
<pango>
looks fine
<pango>
ocamlopt -S and look at asm ;)
<dylan>
if only it wasn't x86 asm...
<dylan>
hehe, I could make a generic "let's ignore exceptions!" function: let safe f x = try Some (f x) with _ -> None
<pango>
or let safe l = try Some (Lazy.force l) with _ -> None
<dylan>
hmm. Or a function that returns a tuple of ('a, exn), then use match on the exn.
<pango>
# safe (lazy (1 / 0)) ;;
<pango>
- : int option = None
<dylan>
hmm
<dylan>
safe : 'a Lazy.t -> ('a option, exn option) ... but that seems like overkill.
<pango>
yup :)
<dylan>
But fun
<dylan>
Every once and a while I wish I could have a function rewrite patterns, or a function that could return a pattern. Usually I chalk it up to madness and have a cup of tea. :P
<pango>
some recommend giving up pure functional style when reading files (or directories)
<dylan>
Using Stack might be a good idea.
<pango>
let files = ref [] in try while true do files := readdir dir :: !files done with End_of_file -> closedir dir ...
<dylan>
I'm actually porting a function I wrote in perl.
<dylan>
which is mostly functional.
<pango>
another idea would be to use HOF... Dir.map or something like that