<goltrpoat>
so i'm trying out ocaml (after doing a fair bit of haskell).. is there anything wrong with the type signature fun : int -> int -> unit, or something along those lines? ocamlc complains about a syntax error at the " :" characters
<goltrpoat>
(this is followed by let rec fun = ...)
<ketty>
goltrpoat: val: int -> int -> unit
<ketty>
eehh sorry
<ketty>
goltrpoat: val name: int -> int -> unit
<goltrpoat>
tried that, it doesn't seem to like val
<goltrpoat>
the function is let rec sierpinskiTri x y size = ...
<goltrpoat>
tried both val sierpinskiTri : int -> int -> int -> unit and sierpinskiTri : int -> int -> int -> unit
<goltrpoat>
(compiles/runs fine without the type signature)
<pango>
compile with ocamlc -i to display the inferred signatures
<ketty>
yes, do that :)
smimou has quit ["bli"]
<goltrpoat>
something along the lines of ocamlc graphics.cma c:/ocaml/test.ml -o -i test.exe ? sorry about the dumb questions, just started looking at it today
<goltrpoat>
(that doesn't seem to print out anything)
<goltrpoat>
er. -i -o test.exe
<ketty>
just: ocamlc graphics.cma -i test.ml
<goltrpoat>
yah i get the same type signature i was using
<goltrpoat>
val sierpinskyTri : float -> float -> float -> unit (i typed int when i meant float earlier)
<ketty>
than you were using the correct signature :)
<goltrpoat>
yah but that doesn't compile :)
<ketty>
did you put it in a *.mli file?
<goltrpoat>
oh.. no, it's an .ml file
<ketty>
than it wont work :)
<goltrpoat>
ohh i see
<goltrpoat>
type signatures have to be in an .mli ?
<ketty>
yes
<goltrpoat>
doh! thanks :)
<goltrpoat>
so, dumb question #2: how do you write a lambda expression with more than one free variable? eg function x y -> stuff, except correctly? (in other words, is there shorthand for function x -> (function y -> (function z -> ... )) )
<ketty>
function x y -> stuff
<ketty>
should work :)
<goltrpoat>
function x y -> x*y;; gives a syntax error at y in the REPL
<ketty>
oh...
<ketty>
you have to use "fun" instead of "function"
<goltrpoat>
ahh
<ketty>
a bit confusing.. :/
<goltrpoat>
what's the difference?
<goltrpoat>
other than the multiple free variables i mean
<ketty>
i think "function" does multiple pattern-matching
<ketty>
and fun does not
<goltrpoat>
oh i see
<ketty>
but in the revised syntax "fun" is used for both cased, as far as i know...
<smimou>
well I also did prepa, I might have known yours
<Fallenou>
which prepa ?
<Fallenou>
(you did prepa in france ? :o
<smimou>
yes Henri IV in Paris
<Fallenou>
ho ho :)
<zmdkrbou>
(half of this chan is french, Fallenou :p)
<Fallenou>
very good prepa
<Fallenou>
ok
<Fallenou>
so you speack french =)
<zmdkrbou>
yes :)
<smimou>
heh
<Fallenou>
ça m'entraine a l'écrit
<smimou>
however we keep it in english for the other half of the chan
<smimou>
:)
<Fallenou>
ok
<zmdkrbou>
but that's supposed to be an english speaking channel, that's uncool for those who don't speak french not to do so
<Fallenou>
well it doesn't work :p
<Fallenou>
evalt [|"-3";"abs"|];;
<Fallenou>
#Exception non rattrapée: Invalid_argument "vect_item"
<Fallenou>
:'(
<smimou>
you're trying to access an element too far in the vect I guess
<Fallenou>
yes
<Fallenou>
ok i see the problem
<pango>
have you only been told about imperative features of the language ? that code doesn't look too "camlish"... arrays, references,... and only ints and strings...
<Fallenou>
s/size/size - 2
<Fallenou>
they told us basic instructions like for, while, match, if
<Fallenou>
avec some operators
<Fallenou>
and*
<Fallenou>
i have experience in C, and php
<pango>
it shows ;)
<Fallenou>
i started caml 2 months ago i think
<Fallenou>
or a little more
<smimou>
I though the info option started sooner
<Fallenou>
it works
<pango>
it seems they did s/Pascal/caml light/g over their old courses
<Fallenou>
the info option started with the 2d "trimestre"
<Fallenou>
during the first one i did SI
<Fallenou>
we had to choose after 3 months
<Fallenou>
wether info (without having done it) or SI
<Fallenou>
so i have to add the operator feature
<Fallenou>
:p
<pango>
what I mean is, if you code matches what you're being told about the language, it's sad
<Fallenou>
yes :s
<Fallenou>
oh yes it seems to work :)
<Fallenou>
it evaluate postfixed algebric expressions
<pango>
maybe your professors made their last efforts to learn new languages in around '75
<Fallenou>
just like in old HP calculator
<Fallenou>
my professor is MP* math professor
<Fallenou>
so informatic is not his speciality
<pango>
it probably explains the problem, rather than justify it
<_jol_>
is there a lot of "nopaste" websites supporting ocaml syntax hilighting ?
<pango>
first has no ads, second keeps settings between pastes, pick your poison ;)
<_jol_>
;)
_jol_ has quit ["c'est l'heure du goûter !"]
<zmdkrbou>
*.dial* ... gloups
<smimou>
?
<zmdkrbou>
dialup connection ? :s
<zmdkrbou>
(it's .fbx.proxad.net, usually)
<Fallenou>
finally it works very good !
<Fallenou>
thank you very much to all who helped me :) ( smimou zmdkrbou pango ! )
* zmdkrbou
didn't help, so np :D
<dylan>
"smimou zmdkrbou pango" should be the name of an alcoholic beverage.
<zmdkrbou>
hihi
<pango>
dylan: after usage
<dylan>
pango: what?
<pango>
dylan: maybe how it's spelt after a few drinks
<dylan>
hmm, I am not sure how to pronounce smimou or zmdkrbou.
<pango>
with difficulty
<zmdkrbou>
rhoo, smimou is easy
damg|food is now known as atla^isn^nup
<dylan>
I'm imagining the vowel sounds are not what I'd assume.
<pango>
zmdkrbou: yes, that's just how the whole catenated thing looks like
<dylan>
zmdkrbou: "zemdarkerboo"?
<pango>
Fallenou: is there something about functional programming panned in your info courses ? That wouldn't look out-of-place, coming from a math prof
<zmdkrbou>
dylan: there's a simple trick : someone (damn him) compressed my nickname because it cas too long, so you can pronounce the original one : themadkaribou
<zmdkrbou>
(much easier to say, huh ? :p)
<Fallenou>
(i don't understand very well the question in english :s)
<zmdkrbou>
Fallenou: your caml code looks like imperative programming
<Fallenou>
imperative ?
<zmdkrbou>
like C
<pango>
Fallenou: functional programming has strong mathematical background (and in fact looks as much as mathematics as a programming language can)
<Fallenou>
well i program in caml like i program in c i think :s
<dylan>
So, "Samuel Mimram Mad Karibou Pango Bang liquor, for that authentic lambda flavor."
<zmdkrbou>
:D
<dylan>
(I pronounce ! as 'bang')
<zmdkrbou>
Fallenou: caml il more about "let f x = blabla in f something" kind of things
<Fallenou>
yes my teacher uses this sort of coding
<Fallenou>
but i dislike ^^"
<zmdkrbou>
rhoooo :)
<Fallenou>
yes i am very "C coding fan"
<zmdkrbou>
that's such a nice programming style :)
<Fallenou>
i create a function
<Fallenou>
i use it after
<zmdkrbou>
you also do this in ocaml
<zmdkrbou>
but you compute values instead of using side-effects
<Fallenou>
someone want my code to evaluate postfixed algebric expressions ?
<Fallenou>
like in old HP calculators
<Fallenou>
like "3 3 +" = 6
<Fallenou>
"3 4 5 + -" = in fact 3 - (4 + 5)
<Fallenou>
and "3 4 sin +" = 3 + sin 4 :p
<Fallenou>
etc
<zmdkrbou>
that's a classical exercice :)
<Fallenou>
ok lol
<Fallenou>
my teacher didn't told us to do it but i wanted to do so
<zmdkrbou>
that's a good idea ... why don't you re-do it in a functional style ? :p
* zmdkrbou
functional zealot
<Fallenou>
=)
<pango>
and uses lists instead of arrays ;)
<pango>
stacks are trivially implemented using lists
<zmdkrbou>
(or using Stack in stdlib :p)
<Fallenou>
we just begin to study stacks
<Fallenou>
before doing this i will implement it in C :p
<Fallenou>
it will be harder without "match with" of caml :p
<pango>
# let rec evalt = function
<pango>
| "+" :: a :: b :: q -> evalt (addf a b :: q)
<pango>
| ...
<Fallenou>
humm
<Fallenou>
yes i can be shorter than mine
<Fallenou>
and more beautiful and "caml look"
<pango>
(addf taking care of string <-> int conversions; it would be even better to use a list of variant types, of course)
<pango>
# type stack_element = Number of int | Operator of string
<pango>
let rec evalt = function
<pango>
| Operator "+" :: Number a :: Number b :: q -> evalt (Number (a+b) :: q)
<pango>
| ...
<Fallenou>
ola
<Fallenou>
too hard for me :p
<Fallenou>
we did't study how to make types
<dylan>
heh
finelemon has joined #ocaml
finelemo1 has quit [Read error: 104 (Connection reset by peer)]
_jol_ has joined #ocaml
mikeX has joined #ocaml
<pango>
actually you only need a stack for partial results, not for the "program"
<metaperl>
pango: thanks for your help on my paste earlier this morning
<pango>
is the "program" necessarily a string array ? again a string list could help
mikeX has quit [Nick collision from services.]
mikeX_ is now known as mikeX
<Fallenou>
it could be a string array or a string list or a string with " " to separate
<zmdkrbou>
then a string list is better : List.fold_left is the best function in the universe :)
<Fallenou>
what does it do ?
<zmdkrbou>
if applies a function on all the elements of a list, keeping a value that is modified on each call and passed to the next call ...
<zmdkrbou>
(not very good explanation :s)
<zmdkrbou>
but it's very powerful
<Fallenou>
hum ok :o
<zmdkrbou>
your teacher will explain you this better than me i think :)
<Fallenou>
with my small knowledge i am happy that my fonction works :p
<Fallenou>
i expect :p
<Fallenou>
thank you very much
<zmdkrbou>
np
<Fallenou>
i have to go, my math book is calling me :p
<metaperl>
I'm having problems with this "as" stmt... also I think my attempt to use not is going to fail as well... help needed: http://ocaml.pastebin.com/729744
finelemon has quit [Read error: 110 (Connection timed out)]
<Smerdyakov>
You have a MS in CS and you don't know what the question is asking?
<pango>
metaperl: you should check the definition of vertices and edges, because you already answered that question :)
<metaperl>
hmm
<metaperl>
insert_vtx inserted a vertex, but how could you insert a vertex... ah
<metaperl>
you would just insert 1,[]
<metaperl>
to insert a vertex
<metaperl>
an edit would have that list non-empty I take it
<metaperl>
does anyone know why this movie "The Davinci Code" is so popular?
<pango>
recursivity is involved there too ;)
<metaperl>
lol
<metaperl>
how many of you French people actually think that France beat Brazil in World Cup 98?
<zmdkrbou>
...
<metaperl>
I mean, as opposed to Brasil laying down because they were paid to lose?
<metaperl>
Zidane is a great player and those were some great headers... but...
<metaperl>
the more I hear and think about it, the less I believe that France won as much as I think that Brasil was paid to lose
<pango>
is it explained in davinci code, too ?
<love-pingoo>
lol
<metaperl>
I hope I can still get IRC help from the French people here after this controversial statement
<zmdkrbou>
i believe so :)
<metaperl>
after all Thierry Henry is one of my favorite strikers
<zmdkrbou>
metaperl: no problem, my opinion on the subject is something like ... "football sucks polar bears" :)
<love-pingoo>
pango: if you look carefully at the position of the players on the field at some point of the match, the brazilians were drawing a large $
<metaperl>
LOL
<love-pingoo>
another chocking statement: I'm quitting OCaml, I'm going Erlang
<love-pingoo>
that's not (yet) truc
<love-pingoo>
-c+e
<zmdkrbou>
love-pingoo: appfffffffffff
<Smerdyakov>
love-pingoo, have you used Concurrent ML, in OCaml's Event module or elsewhere?
<love-pingoo>
but I'm sick of Ocaml's problems with threads and signals
<Smerdyakov>
I never use signals. Why do you care about them?
<love-pingoo>
Unix.alarm uses a signal
<zmdkrbou>
love-pingoo: as long as this is just for liq ...
<Smerdyakov>
There are more idiomatic Concurrent ML ways to accomplish Unix.alarm's functionality; namely, the timeout event.
<love-pingoo>
here's a simple thing I do: install a handler on siglarm, which does exit 2, then schedule an alarm in 20 seconds, then start downloading some file
<love-pingoo>
and it works.. until some of these processes simply freezes
<Smerdyakov>
Doesn't seem to be present in OCaml's Event, but it is in the "real" CML.
<love-pingoo>
then I use a thread, which does (Thread.delay 20. ; exit 2)... same story
<Smerdyakov>
love-pingoo, really, signals are garbage. Try CML..
<love-pingoo>
Smerdyakov: I have difficulties believing that the Event module behaves better than a simple Thread.delay
<Smerdyakov>
love-pingoo, I don't know. Since it doesn't have timeOutEvt, probably not. But if you switch to SML, I believe this would work perfectly.
<love-pingoo>
at this point it's too late
<Smerdyakov>
You simply create a compound event, waiting for one of the file download to finish or a timeOutEvt.
<love-pingoo>
sml's threads are native ones ?
<Smerdyakov>
No.
<Smerdyakov>
It's an implementation issue, but the SML/NJ and MLton CML implementations both use lightweight user-level threads.
<love-pingoo>
maybe Ocaml should, too, since its threads cannot really execute concurrently
<Smerdyakov>
Everything that runs on UNIX should!
_jol_ has joined #ocaml
<Schmurtz>
you may also use select from the Unix package
<love-pingoo>
so, seriously, I might take a look at Erlang some day, at least that's an interesting success story
<love-pingoo>
Schmurtz: Thread.delay is a call to Unix.select
<Schmurtz>
strange
<love-pingoo>
Schmurtz: indeed
<Smerdyakov>
love-pingoo, Concurrent ML has everything that Erlang has, but with awesome additional features enabled by static typing.
<Schmurtz>
select has nothing to do with threads
<love-pingoo>
strange and sad and tiring :(
<love-pingoo>
Smerdyakov: Erlang runs some real-world applications
<Smerdyakov>
love-pingoo, so does SML..
<creichen>
Smerdyakov: I disagree about user-level threads. Using user-level threads means that all of your execution will get stuck if one thread gets stuck in kernel space. They are a valid implementation choice, but not inherently superior to using, say, 'clone', where available.
<love-pingoo>
Smerdyakov: with weird freezes such as the one I depicted, I'd say it's a bit tricky to get something running
<Smerdyakov>
love-pingoo, what does that have to do with SML?
<love-pingoo>
ah, sorry
<love-pingoo>
Smerdyakov: any link to such applications ?
<love-pingoo>
just curious..
<Smerdyakov>
http://hcoop.net/ dynamic web sites and user-level management tools are all written by me in SML.
<love-pingoo>
creichen: I was looking for some multithreaded stuff, servers and so on.. I'll look at hcoop
<zmdkrbou>
theorem provers are not really relevant examples ...
<creichen>
love-pingoo: Sorry, I thought you only wanted "real-world apps".
<Smerdyakov>
zmdkrbou, I guess based on your definition of "real world"?
<Smerdyakov>
zmdkrbou, big processor manufacturers do use computer theorem proving tools as part of their standard quality control procedures today.
<love-pingoo>
Smerdyakov: sorry but that doesn't convince me.. is there a single daemon running for months and bearing heavy load written in SML ?
<Smerdyakov>
love-pingoo, no
<dylan>
or nifty applications like wyrd, unison, and ml-donkey? :)
<pango>
what about Smerdyakov himself ? :)
<Smerdyakov>
love-pingoo, I've done that before, though, but I don't know about measuring the heavyness of the load.
<love-pingoo>
lol
<zmdkrbou>
Smerdyakov: the problem is just that the people who code theorem provers are almost the same as those who design functional languages : all research people ...
<love-pingoo>
Smerdyakov: actually I don't care about load, but I do want stability for months
<zmdkrbou>
and it doesn't use much threads and stuff like this
<Smerdyakov>
love-pingoo, I don't have any reason to doubt the stability of a daemon compiled with MLton.
<love-pingoo>
btw, speaking mldonkey: the daemon is reloaded every 24 hours
<love-pingoo>
they have a script to do that, they say it's safer..
<dylan>
love-pingoo: for the love of... pingoo, why?
<pango>
more because of memory usage than stability...
<love-pingoo>
pango: is it so poorly coded that I has memory leaks in spite of the Gc ?
<smimou>
ahahah years and years of research and you still end up with dirty hacks...
<zmdkrbou>
:)
<pango>
love-pingoo: the script is also not provided with mldonkey
<love-pingoo>
yeah but it's in the debian installation
<pango>
love-pingoo: debian provides year old version
<zmdkrbou>
wouhou : fight!
<love-pingoo>
I'd love to hear that it's not needed anymore
<love-pingoo>
I'm not fighting, I just want my programming to be easier
<smimou>
2.7.3-2
<smimou>
is that so old ?
<love-pingoo>
2.7.6 is on freshmeat today
<smimou>
(2.7.3 = 19 Jan 2006)
<zmdkrbou>
mmmh, no better on gentoo
<love-pingoo>
wow they release more often than us :D
<pango>
I can't really provide examples of high uptimes, I'm testing new patches all the time ;)
<pango>
but current uptime is > 5 days, RSS 60MB...
<love-pingoo>
ouch
<pango>
that's a constant, it takes ~ 50MB after a few minutes
<love-pingoo>
ok
<smimou>
well firefox or thunderbird tend to take that much too
<pango>
I remember upgrading the box from 256MB to 512MB few years ago because of serious leaks at the time... I can't say they're all gone, but it's now in "acceptable range" again ;)
<love-pingoo>
hey, project idea: rewrite firefox in OCaml :)
<pango>
then go on with openoffice ;)
<Smerdyakov>
Then Pong !
chessguy has joined #ocaml
<love-pingoo>
first, do we have a text editor ?
<love-pingoo>
efuns is dead
<smimou>
bed !
* zmdkrbou
.oO(hem)
<pango>
the problem is that you need some "critical mass" of devs and users for a projet to survive
<love-pingoo>
there are enough OCaml developers..
<love-pingoo>
haskell has the yi editor
<zmdkrbou>
boarf, it depends on the project
<pango>
language of implementation is not in the "top features list" of most users, so you must provide more than just the reimplementation of something that exists
<love-pingoo>
pango: you're right actually
<love-pingoo>
I was half kidding.. but I'm surprised nobody tried, except efuns
ketty has quit [Read error: 110 (Connection timed out)]
<pango>
(mldonkey barely reaches the critical mass of devs btw)
V has joined #ocaml
<love-pingoo>
does it really do more than other existing software
<love-pingoo>
?
Schmurtz has quit [Read error: 113 (No route to host)]
<mikeX>
well it has nice core/frontend separation for one thing
<pango>
yes... the multi users support that's in the making will probably be another unique feature
<pango>
several clients now have multi networks supports, but it was a unique feature for some time, too
<love-pingoo>
I'm not sure that's such an important feature
<love-pingoo>
do you really use many networks at the same time ?
<pango>
and its "unixish" touch (works as a daemon, as already mentionned; but also telnet interface with internal commands interpreter, hooks for calling external scripts...)
<ketty>
mikeX: let () = ... is used when you have something that evaluates to unit
<mikeX>
isn't that like 'let _ = ...'?
<ketty>
yes
<ketty>
except it has to be unit
<ketty>
while _ can be anything
<ketty>
so it is more specific
<mikeX>
oh ok, cause let () messes up the toplevel
<ketty>
how?
<mikeX>
# let () = print_string "hi";;
<mikeX>
hi#
<mikeX>
# let _ = print_string "hi";;
<mikeX>
hi- : unit = ()
<mikeX>
#
<ketty>
where is the mess?
<mikeX>
hmm, I must be missing something
<ketty>
# let () = ();;
<ketty>
# ();;
<ketty>
- : unit = ()
<ketty>
there is no "response" from the system in case of let () = ...
<mikeX>
yes indeed
<mikeX>
still I find it confusing (using () as an l-value)
<ketty>
it is better than using _
<ketty>
as type errors will be caught..
<mikeX>
yes I understand that, what confuses me is the very notion that you can do it
<mikeX>
(use it as an l-value)
<ketty>
it is pattern matching...
<ketty>
just like you can do: let (a, b) = ...
<ketty>
or: let (hd::tl) = ...
<mikeX>
i see
smimram has quit ["bli"]
<ketty>
mikeX: you can even do: let 5 = 5;;
<mikeX>
well that complains
<ketty>
while: let 5 = 7 will result in a Match_failure
<mikeX>
about the matching not being exhaustive
<ketty>
yes it complains
<mikeX>
(first thing I tried, and I actually used 5 )
<ketty>
but it is just a warning
<ketty>
it is not an error
<mikeX>
i think it's starting to sink in
<ketty>
:)
<mikeX>
still Match_failure is a run time error
<ketty>
yes
<ketty>
and run time errors are evil
<ketty>
that is why there is a warning :)
<mikeX>
hehe
<creichen>
mikeX: These things are normally used when you're in a hurry and you know parts of the structure you're going to expect. That structure being different means that something screwed up-- the Match exception (or whatever Ocaml calls it) is then akin to an assertion failure.
<mikeX>
nice
<dylan>
I usally write _ -> assert false or some such.
<creichen>
Smerdyakov: Congratulations on your paper, by the way!