<stardust>
i've read on the o'reilly book that the form 'let f a b = a + b;;' is a lagacy from old versions of caml. is the form 'let f = function a -> function b -> a + b;;' preferred or the former one is the most comonly used?
<stardust>
s/lagacy/legacy/
<stardust>
err, forget it...
<Smerdyakov>
I already forgot it!
<stardust>
i got confused with the 'fun a b = a + b' form
<stardust>
this is the legacy one
Kinners has joined #ocaml
reltuk has quit [SendQ exceeded]
reltuk has joined #ocaml
stardust has quit ["leaving"]
listener has joined #ocaml
<listener>
Is there some equivalent to static local variables in OCaml?
<Kinners>
you can use ref's like this -
<Kinners>
let incr = let var = ref 0 in fun x -> var := !var + x; !var;;
<listener>
Kinners: But I want to define a function.
<listener>
let foo () =
<listener>
let var =ref 0 in
<Kinners>
incr is a function
<listener>
begin
<listener>
var := !var+ 1;
<listener>
var
<listener>
end;;
<listener>
foo always returns 1. I want it to return 1 then 2 then 3 then 4 then 5.
<Kinners>
did you try incr?
<Kinners>
remember that let foo () = ... is the same as let foo = fun () -> ...
<listener>
Yes exactly. I want var to be static. It should retain it's calue.
<listener>
But in foo var gets reset to zero each time.
<Kinners>
yes, but you tried incr right?
<listener>
incr instead of var:= !var +1 :
<listener>
?
<Kinners>
let incr = let var = ref 0 in fun () -> var := !var + 1; !var;;
<Kinners>
that does what you want
<listener>
Yeah it does. But is it risky? Is OCaml statically or dynamically typed?
<listener>
s/typed/scoped/
<Kinners>
statically
<Kinners>
let make_incr base incr = let var = ref base in fun x -> var := !var + incr; !var;;
<Kinners>
a more generic version, let inc5 = make_incr 0 5;;, then, inc5 ();;
Tabu-la-Rasa has quit [Read error: 104 (Connection reset by peer)]
<listener>
Thanks.
<Kinners>
what do you need it for?
<listener>
I might need it to cache input from a file for lookahead.
Tabu-la-Rasa has joined #ocaml
listener has quit [Remote closed the connection]
reltuk has quit [Excess Flood]
reltuk has joined #ocaml
reltuk has quit [SendQ exceeded]
reltuk has joined #ocaml
reltuk has quit [SendQ exceeded]
lus|wazze has joined #ocaml
wax has quit [Read error: 54 (Connection reset by peer)]
wax has joined #ocaml
Kinners has left #ocaml []
__DL__ has quit [Read error: 104 (Connection reset by peer)]
__DL__ has joined #ocaml
zenkov has joined #ocaml
two-face has joined #ocaml
zenkov has quit [Read error: 54 (Connection reset by peer)]
buggs|afk is now known as buggs
lus|wazze` has joined #ocaml
lus|wazze has quit [Read error: 110 (Connection timed out)]
karryall has joined #ocaml
lus|wazze has joined #ocaml
lus|wazze` 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]
lus|wazze has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
buggs|afk has joined #ocaml
malc has joined #ocaml
systems has joined #ocaml
buggs has quit [Read error: 110 (Connection timed out)]
ott has joined #ocaml
<ott>
re all
<two-face>
hi
systems has quit ["Client Exiting"]
malc has quit ["no reason"]
ott has left #ocaml []
Guillaumito has joined #ocaml
<Guillaumito>
hi everybody
<Guillaumito>
when I'm trying to use streams with the [< >] syntax, I get a "syntax error", whats happening ?
<smkl>
you need ocamlc -c -pp camlp4o foo.ml
<Guillaumito>
and with the interactive ocaml ?
<smkl>
#load "camlp4o.cma";; or ocaml camlp4o.cma when you start
<Guillaumito>
ok, thank you
<Guillaumito>
ooo, it works ! :)
<Guillaumito>
thank you very much
* Guillaumito
is away: kfe
* Guillaumito
is back (gone 00:26:40)
mattam_ is now known as mattam
<vect>
8 francais, nouveau record.
<Guillaumito>
on peut parler francais ?
<two-face>
oui
<Guillaumito>
j'ai du reflechir au moins 5 minutes pour formuler ma question en anglais...
<two-face>
waw
<Guillaumito>
j'ai du mal a m'exprimer :)
malc has joined #ocaml
<two-face>
et ta question ?
<Guillaumito>
c'etait sur les stream, mais smkl l'a repondu
<Guillaumito>
et ca fonctionne
<vect>
enfin, on peut parler francais tant que les non francophones semblent pas vouloir intervenir
<Guillaumito>
par contre, je comprend tres bien l'anglais
<vect>
j'ai pas encore eu l'occasion de tester ocaml 3.07 (woody oblige), ca donne quoi, mis a part les 2-3 patches qui sont sortis dans la foulee a cause de bugs stupides ?
<two-face>
ça marche bien
<two-face>
tout se recompile impeccablement
* vect
note
<Guillaumito>
j'utilise ocaml 3.06
<vect>
j'en suis toujours au 3.04
<karryall>
oula
<karryall>
ca commence à faire vieux
<vect>
ben je suis en woody hein, ceci explique cela
<two-face>
faut utiliser testing
<vect>
oui mais bon, j'ai pas trop envie de stresser ma machine
<two-face>
bof
<karryall>
ils ont sorti des nouveaux binaires pour la 3.07 finalement ?
<vect>
au fait, quelqu'un ici connait la methode du point interieur, je trouve pas grand chose de convaiquant pour m'expliquer ce que c'est
<vect>
(rien a voir avec ocaml, je sais)
<two-face>
karryall: non
harry3001_ has joined #ocaml
harry3001_ has left #ocaml []
smkl has quit [Read error: 113 (No route to host)]
<karryall>
vect: c'est quoi ?
<Guillaumito>
justement si il demande :)
* Guillaumito
est desole
<vect>
karryall justement je sais pas, c'est en rapport avec la programmation mathematique / programmation par contrainte, mais j'en sais pas plus.. on me l'a juste citee
<karryall>
ok (j'y connais rien en prog. par contraintes)
<Guillaumito>
moi non plus
<two-face>
j'en ai fais en progol III
<two-face>
prolog
* Guillaumito
is away: parti voir ric
* Guillaumito
is back (gone 00:12:15)
<Guillaumito>
salut, a+
Guillaumito has left #ocaml []
two-face has quit ["Client exiting"]
malc has quit ["no reason"]
karryall has quit [Nick collision from services.]
karryall has joined #ocaml
<det>
can you define mutually recursive functions in ocaml /.
<mellum>
det: sure
<det>
ahh
<det>
I got it
<mellum>
det: use the "and" keyword
<det>
left off the rec keyword
<det>
mellum: yeah, was doing that and getting a variable not bound error, forgot the rec
listener has joined #ocaml
<det>
thanks
<listener>
Hey. I'm trying to write a prgram which produces a list of "words" ( a word is a string of characters that test true given a function "is_word_char" ) from a file. I'mgetting stuck on two things: testing end of file and putting characters back in the stream.
<mellum>
Alphas have VAX compatibility floating points/
<mellum>
oops
smkl has joined #ocaml
rox has quit [Read error: 54 (Connection reset by peer)]
<listener>
how do i test for end of file?
rox has joined #ocaml
<karryall>
listener: you get en End_of_file exception when you've reached it
<listener>
Sigh. No way to *test* for it?
<Riastradh>
let maybe_input_char channel = try Some (input_char channel) with End_of_file -> None
<Riastradh>
match maybe_input_char channel with
<Riastradh>
Some char -> (* success *)
<Riastradh>
| None -> (* end of file *)
<listener>
You've missed an "in" before match. Doesn't this change the position of the channel?
<Riastradh>
No, I didn't miss an 'in'; I intended the first expression to be a function definition at the top level for use elsewhere.
systems has joined #ocaml
systems has quit ["Client Exiting"]
lus|wazze has quit ["And all those "If you're living like there is no hell, you'd better be right" bumper stickers are just Pascal's Wager transla]
listener has quit [Read error: 113 (No route to host)]
buggs|afk is now known as buggs
karryall has quit ["ERC vVersion 3.0 $Revision: 1.328 $ (IRC client for Emacs)"]
listener has joined #ocaml
<listener>
Is there a way to convert a char into a string?
<Smerdyakov>
I'm assuming you're asking for a single standard function : char -> string, since it's obvious how to do it after a quick glance at the signature of String.
<listener>
I'm looking at the signatutr now. There is no obvious way. At least no obvious way if you have any aesthetic value whatsoever
<Smerdyakov>
You don't like this?
<Smerdyakov>
let charToString = String.make 1
<listener>
Ahh. I was thinging:
<listener>
let char_to_string c= let s=" " in (s.set 1 c;s );;
<listener>
I missed String.make.
<Riastradh>
You missed the fundamental string creator?
clam has joined #ocaml
systems has joined #ocaml
listener has quit [Read error: 113 (No route to host)]