multi_io has quit [Read error: 60 (Operation timed out)]
CiscoKid has joined #ocaml
bk_ has quit ["leaving"]
__DL__ has quit ["Bye Bye"]
sundeep has quit ["Client exiting"]
<tyl3r>
i want to do a simple tree update (e.g. a function is modifying a tree and i want the new tree to be returned and available for the caller function), what should I do ?
<tyl3r>
(say add() is returning the updated tree)
<tyl3r>
and mytree is the name of my original tree
<tyl3r>
i know its really stupid, but its a beginner question
<CiscoKid>
Not quite sure what you mean. Are you using Map or Set or something similar?
<tyl3r>
im using my own type 'a btree = 'a * 'a btree * 'a btree
<tyl3r>
with my own working add() function
<CiscoKid>
What's the confusion, exactly?
<tyl3r>
i just want to get my updated tree in the caller fonction
<CiscoKid>
Isn't that what happens when you call add?
<tyl3r>
nope, the tree is returned, if I use it immediately then its good, but if I want to use it some lines after, the local tree is still the old one
jdrake has joined #ocaml
<CiscoKid>
Right, so you returned it, that means you have the modified one.
<tyl3r>
let
<tyl3r>
mytree = Cons(41, Nil, Nil) and
<tyl3r>
in
<tyl3r>
printf "Entering bottom func !\n";
<tyl3r>
mytree (add 40 mytree cmp);
<tyl3r>
ptree mytree;
<jdrake>
(in a hopefully unbiased manner...) how would one choose between ocaml and sml (or why would they choose one or the other)
<tyl3r>
CiscoKid: sorry, wrong paste
<tyl3r>
let
<tyl3r>
mytree = Cons(41, Nil, Nil) and
<tyl3r>
in
<tyl3r>
printf "Entering bottom func !\n";
<tyl3r>
printree (add 40 mytree cmp);
<tyl3r>
printree mytree;
<tyl3r>
the first printree does not print the same thing that the second one
<tyl3r>
the second printree prints the old tree
<CiscoKid>
I'd try both, honestly. Although, I've not tried SML since I've been so happy with OCaml. :)
<tyl3r>
how can I just save the new tree into mytree thats my question, simple
<CiscoKid>
You're trying to do something in a non-functional style.
<CiscoKid>
I'm not sure what you're actually trying to do, though. It's not a terribly practical example, so I can't rightly derive what you mean. :)
<tyl3r>
i want to add a fucking element into a tree man
<tyl3r>
:)
<CiscoKid>
You did.
<CiscoKid>
You have a functional tree, much like the Set module.
<tyl3r>
i dont want my second printree to print the old tree (the one before the element insertion)
<tyl3r>
and thats what this code is doing
<jdrake>
one thing I never really liked in ocaml was its record members having a global namespace (or whatever you want to call the terms)
<CiscoKid>
BTW, your arguments seem backwards. I'd go with (add mytree cmp 40)
<CiscoKid>
jdrake: Yeah, that really sucks, it's very counterintuitive.
<tyl3r>
CiscoKid: i coded my own add function, thats not my question, the add function is working perfectly and I dont want to change it
<CiscoKid>
The point is that you're doing something you wouldn't typically do in a functional style. You could do another let binding for the one example, but it's not very functional.
<CiscoKid>
I understand you coded your own add function, I'm just suggesting that your parameters are added in a non-optimal style.
<tyl3r>
so if I understand well, i need to pass the modified tree as a parameter to another function so that my code keeps a functionnal style
<tyl3r>
and so that I dont do affectations
<CiscoKid>
If you're trying to build the tree from a list, for example, you could just fold the list over the tree add function.
<CiscoKid>
Or do a let binding if you really just want to add one.
<CiscoKid>
For example:
<CiscoKid>
module StringSet = Set.Make(String);;
<CiscoKid>
let x = List.fold_left (fun a b -> StringSet.add b a) StringSet.empty ["c"; "b"; "a"];;
<CiscoKid>
StringSet.iter print_endline x;;
<CiscoKid>
That stupid lambda is in there because Set has its arguments in the wrong order (like your add function) for the list fold, otherwise it'd just be StringSet.add
<CiscoKid>
The ``problem'' you're running into is the consistency provided by the lack of variables in functional languages. In order to get the effect you are asking for in the listing you provided, you'd have to introduce a side-effect.
<tyl3r>
yeah, I understand that
<tyl3r>
thanks, I'm out
Snark has joined #ocaml
<Snark>
slt
_shawn has joined #ocaml
jdrake has quit [Read error: 60 (Operation timed out)]
shawn_ has quit [Read error: 60 (Operation timed out)]
gim has joined #ocaml
CiscoKid has quit ["when commits stop, sleep starts"]
kosmikus|away is now known as kosmikus
pattern has quit [Remote closed the connection]
pattern has joined #ocaml
kosmikus is now known as kosmikus|away
karryall has joined #ocaml
smimou has joined #ocaml
cjohnson has quit [Read error: 110 (Connection timed out)]
vezenchio has joined #ocaml
mellum has quit [zelazny.freenode.net irc.freenode.net]
mellum has joined #ocaml
gl has left #ocaml []
gl has joined #ocaml
karryall has quit [Remote closed the connection]
smimou has quit ["?"]
smimou has joined #ocaml
Zaius has joined #ocaml
karryall has joined #ocaml
Shammah has joined #ocaml
gim has quit [Read error: 60 (Operation timed out)]
platypus has quit [Read error: 60 (Operation timed out)]
platypus has joined #ocaml
cjohnson has joined #ocaml
noss has joined #ocaml
__DL__ has joined #ocaml
phj has joined #ocaml
phubuh has quit [Remote closed the connection]
<phj>
How to open another graph window in ocaml-3.07?
<karryall>
you can't
<phj>
or how to open multi-window with graphics library?
<phj>
why?
<karryall>
because :)
<karryall>
that's the way it's implemented
<phj>
Is there a library which can do that?
<karryall>
Tk or GTK I would say
<phj>
thanks,karryall
<phj>
but where can I found examples on programming with LablTk?
<Snark>
perhaps there is an "examples/" directory in the sources?
<karryall>
there is
smimou has quit ["?"]
fab has joined #ocaml
_fab has quit [Read error: 104 (Connection reset by peer)]
fab is now known as _fab
platypus_ has joined #ocaml
platypus has quit [Connection timed out]
Shammah has quit [Read error: 110 (Connection timed out)]
gim has joined #ocaml
Axioplase has joined #ocaml
<Axioplase>
Chat Lu!
<Axioplase>
(hi)
_fab has quit []
fab has joined #ocaml
fab is now known as _fab
bk_ has joined #ocaml
monotonom has joined #ocaml
_shawn has quit [Read error: 110 (Connection timed out)]
mmc has quit [Operation timed out]
mmc has joined #ocaml
<tyl3r>
anyone can explain me a very simple thing in lambda calculus please
Skal has joined #ocaml
<tyl3r>
true = Lx.Ly.x and false = Lx.Ly.y (with = lambda, the abstraction operator). I thought I understood the stuff, but I dont catch this example
<tyl3r>
(with L = lambda)
<karryall>
which example ?
noss has quit ["Leaving"]
monotonom has left #ocaml []
monotonom has joined #ocaml
Axioplase is now known as Axio|Fac
CiscoKid has joined #ocaml
ravi2box has joined #ocaml
monotonom has quit ["Don't talk to those who talk to themselves."]
<ravi2box>
err..dumb question..which is the best library to write CGI in Ocaml?
<ravi2box>
any alternatives?app server framework like zope?
<CiscoKid>
The ORA book has a servlet engine type thing as an example. That's worked really well in java, it'd be nice to catch on.
bk_ has quit ["leaving"]
<karryall>
there's wdialog , written by G.Stolpmann
ravi2box has quit ["Leaving"]
bk_ has joined #ocaml
phj has quit [Connection timed out]
Zaius has quit [Read error: 54 (Connection reset by peer)]
mmc has quit [Read error: 60 (Operation timed out)]
<CiscoKid>
val dir_iter : string -> (string -> string list -> 'a -> 'b) -> 'a -> 'b
<CiscoKid>
My functions are as follows:
<CiscoKid>
let dir_iter_via lsfunc dir func arg = func dir (lsfunc dir) arg
<CiscoKid>
let dir_iter = dir_iter_via lsdir
<CiscoKid>
I don't quite understand the error. It seems to be implying that my function does the right kind of transformation, but it's declaring it incomptible with my definition.
mmc has joined #ocaml
platypus_ is now known as platypus_zzz
mattam_ has joined #ocaml
gim has joined #ocaml
mattam has quit [Read error: 113 (No route to host)]
jdrake has joined #ocaml
bbz_ has joined #ocaml
bbz_ has left #ocaml []
jdrake has quit [Read error: 60 (Operation timed out)]
bzzbzz has joined #ocaml
valik has quit ["ChatZilla 0.9.59 [Mozilla rv:1.7a/20040219]"]
jdrake has joined #ocaml
Submarine has joined #ocaml
<Submarine>
hi there... wow, I wasn't aware there was such a big channel
* Submarine
has just ported a big Caml program to Win32
<CiscoKid>
It's mostly quiet.
<smkl>
CiscoKid: you need to eta expand it, let dir_iter a b = dir_iter_via lsdir a b
<CiscoKid>
I tried that as well, it didn't seem to make a difference over currying.
Snark has quit ["Parti"]
<smkl>
did you try with let dir_iter a b c = .. too
<CiscoKid>
Yeah, I finally gave up and just copied the bodies. I got work to do. :)
Phreaze has joined #ocaml
<smkl>
well anyway, "let dir_iter a = dir_iter_via lsdir a" does work, because it's a function, not value declaration
<CiscoKid>
The error was suggesting that they were *almost* the same, except where one had 'a, the other had '_a
<CiscoKid>
It's like, ocaml knew that they did the same thing, but couldn't accept that they did them with the same things.
<smkl>
it's the value description ... '_a are kind of existential type vars that get instantiated when they are used
<smkl>
err restriction
<smkl>
like let a = ref (fun x -> x);; a := (fun x -> x+1);;
mkorman has joined #ocaml
<mkorman>
is there any way to view object members in ocamldebug?
Axioplase has quit [Read error: 110 (Connection timed out)]
bzzbzz has left #ocaml []
Phreaze is now known as Axioplase
karryall has quit [Ping timeout: 14400 seconds]
Submarine has left #ocaml []
jdrake has quit [Read error: 60 (Operation timed out)]
bzzbzz has joined #ocaml
<CiscoKid>
Hashtbl seems to have a lot of memory overhead. It's taking me about 140MB of memory to store less than 40MB of text in two hashtables (two column data, one int, one string, and reversed).
bzzbzz has quit [Read error: 104 (Connection reset by peer)]
bzzbzz has joined #ocaml
Skal has quit ["Client exiting"]
tyler_ has joined #ocaml
bzzbzz has quit ["Killed (BillGates (Lindows 98 -- jizz your pants!))"]
<tyler_>
anyone has an exemple of code removing an element in a tree ?
<tyler_>
please :)
<Riastradh>
tyler_, uh, you'll have to describe your problem in a wee bit more detail first.
<CiscoKid>
What kind of tree? Like a Set or Map instance?
<CiscoKid>
Set.remove will do it.
<tyler_>
i just want to remove an element from a generic tree, giving a cmp function
<tyler_>
my actual code, (which compiles but does not work) is :
<Riastradh>
What sort of tree?
<tyler_>
let rec newg t1 t2 = match (t1,t2) with
<tyler_>
(t1, Nil) -> t1 |
<tyler_>
(Nil, t2) -> t2 |
<tyler_>
(Cons(a, b, c), Cons(d, e, f)) -> if a < d then Cons(a, (newg b c), Cons(d, e, f)) else Cons(d, Cons(a, b, c), (newg e f));;
<tyler_>
let rec rem elm tree cmp = match tree with
<tyler_>
Nil -> Nil |
<tyler_>
Cons(a, Nil, c) -> if a = elm then c else (rem elm c cmp) |
<tyler_>
Cons(a, b, Nil) -> if a = elm then b else (rem elm b cmp) |
<tyler_>
Cons(a, Cons(b1, b2, b3), c) -> if (mem elm tree cmp) = false then tree else
<tyler_>
(if cmp a elm = 0 then (Cons(b1, (rem elm b2 cmp), (rem elm (newg b3 c) cmp))) else
<tyler_>
Cons(a, (rem elm (Cons(b1, b2, b3)) cmp), (rem elm c cmp)));;
<tyler_>
Riastradh, generic one : type 'a btree = 'a * 'a btree * 'a btree
<tyler_>
im sorry I'm new to ocaml, I cant use the ocaml library to do that because it is an exercice that I have to do
<tyler_>
mem elm tree cmp beeing a function returning true if the element is in the tree, false if its not
<CiscoKid>
Why is mem used in there?
<CiscoKid>
It's a bit confusing. You're checking for your element from the top of the tree during your recursion. Why not just match on Cons(a,b,c) and return Cons(a, (rem ... b ...) (rem ... c ...)) ?
GreyLensman has joined #ocaml
cmeme has quit [Read error: 54 (Connection reset by peer)]