<d_bot>
<orbitz> You've got to consume a list or commands and a tree. So start writing a function that does that
<d_bot>
<orbitz> It'll be a recursive function
<d_bot>
<romachkuna> yes right , i was thinking to put the tree nodes into the list and start constructing the new one with the commands order
<d_bot>
<romachkuna> the UP commands seems little tricky
hyphen has quit [Quit: leaving]
hyphen has joined #ocaml
Haudegen has joined #ocaml
hyphen has quit [Quit: leaving]
hyphen has joined #ocaml
hyphen has quit [Quit: leaving]
hyphen has joined #ocaml
hyphen has quit [Client Quit]
hyphen has joined #ocaml
hyphen has quit [Client Quit]
hyphen has joined #ocaml
hyphen has quit [Client Quit]
hyphen has joined #ocaml
hyphen has quit [Client Quit]
hyphen has joined #ocaml
conjunctive has quit [Ping timeout: 245 seconds]
azimut has quit [Remote host closed the connection]
conjunctive has joined #ocaml
azimut has joined #ocaml
gravicappa has joined #ocaml
bartholin has quit [Quit: Leaving]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
waleee has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
vicfred has quit [Quit: Leaving]
vicfred has joined #ocaml
<Corbin>
Do folks always rewrite folds to the correct direction in order to get optimized tail calls? How costly is it to reverse a list before folding it instead?
<d_bot>
<nave01314> Well, if f is commutative, then it’s not very hard to rewrite
<d_bot>
<nave01314> In general I would use fold_right bc it’s more efficient, unless I had a use case where fold order mattered and I needed left to right
<sleepydog>
Corbin: I don't rewrite it if I know the list is small and rewriting it makes it harder to read
<sleepydog>
the tail_modulo_cons annotation in 4.14 seems to give you the best of both worlds
<Corbin>
Is folding to the left more efficient than reversing and folding to the right?
Guest52 has joined #ocaml
Guest52 has quit [Client Quit]
<sleepydog>
i dunno that it's more efficient, folding to the right just has the problem of using stack space relative to the size of the input
<Corbin>
Sure. I'm currently implementing a CAM with bytecode and stack layout similar to OCaml, and I'm trying to understand whether I would prefer to have two fold directions, or one fold and a list-reversal primitive.
mro has quit [Remote host closed the connection]
<d_bot>
<nave01314> my understanding is that `fold_left` is tail-recursive but requires reversing the list at the end, whereas `fold_right` is not tail-recursive and doesn't require reversing
<d_bot>
<Alistair> `fold_left` is tail recursive, but no reversal is performed (this is performed by the caller if required) e.g. reversal isn't required for commutative operations, such as summing a list
mro has joined #ocaml
rgrinberg has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
hyphen has quit [Ping timeout: 250 seconds]
mro has quit [Remote host closed the connection]
hyphen has joined #ocaml
motherfsck has quit [Ping timeout: 246 seconds]
rgrinberg has quit [Ping timeout: 248 seconds]
shawnw has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
vicfred has quit [Quit: Leaving]
mro has joined #ocaml
motherfsck has joined #ocaml
mro has quit [Client Quit]
bartholin has joined #ocaml
dextaa has joined #ocaml
hyphen has quit [Ping timeout: 246 seconds]
hyphen has joined #ocaml
hyphen has quit [Ping timeout: 256 seconds]
hyphen has joined #ocaml
bartholin has quit [Ping timeout: 246 seconds]
bartholin has joined #ocaml
gravicappa has quit [Ping timeout: 248 seconds]
vicfred has joined #ocaml
<d_bot>
<Ambika E.> I want to execute GNU `diff` on a user-provided filename and retrieve the exit code; is there a safe(r) way to do this compared to Sys.command ?
hyphen has quit [Ping timeout: 250 seconds]
hyphen has joined #ocaml
dextaa has quit [Ping timeout: 256 seconds]
bartholin has quit [Ping timeout: 272 seconds]
hyphen has quit [Ping timeout: 256 seconds]
<d_bot>
<romachkuna> is there any way to access parent node of given value? in binary tree
<d_bot>
<Ambika E.> usually no
<d_bot>
<Ambika E.> each node is its own independent binary tree with no knowledge of whether or not it's actually a subtree in a larger tree
hyphen has joined #ocaml
bartholin has joined #ocaml
hyphen has quit [Read error: Connection reset by peer]
bartholin has quit [Quit: Leaving]
<d_bot>
<Alistair> You'll either need to pass the parent down as an argument, or add a reference back to the parent
m5zs7k has quit [Quit: m5zs7k]
<d_bot>
<KW78> ? add a reference -> an action to be performed by the parent upon return of the function (eg Delete)