vivanov has quit [Read error: Connection reset by peer]
vivanov_ has joined #ocaml
avsm has joined #ocaml
vivanov_ has quit [Ping timeout: 276 seconds]
ikaros has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
nejimban has quit [Ping timeout: 276 seconds]
Cyanure has joined #ocaml
vivanov has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
iratsu has joined #ocaml
Anarchos has joined #ocaml
Vinnipeg has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
avsm has quit [Quit: Leaving.]
vivanov has quit [Quit: Lost terminal]
lopex has joined #ocaml
Cyanure has quit [Remote host closed the connection]
Vinnipeg has quit [Quit: Ухожу я от вас (xchat 2.4.5 или старше)]
Tobu_ has quit [Quit: No Ping reply in 210 seconds.]
Tobu has joined #ocaml
BiDOrD has joined #ocaml
jmcarthur has joined #ocaml
BiDOrD_ has quit [Ping timeout: 276 seconds]
ygrek has joined #ocaml
Anarchos has joined #ocaml
vivanov has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
pixelou has joined #ocaml
<pixelou>
hi ! I'm new to ocaml and i'd just like to know hw to pass a reference to a fonction (I don't see how to do what I want without this)
<zorun>
when passing an array to a function, it is actually passed as a reference
<zorun>
don't know if it is your goal
<zorun>
any non-mutable type (eg. a list) can't be passed by reference, obviously
<pixelou>
It was for a single variable at first
<pixelou>
not an array
<zorun>
in a functional language, the term « variable » generally does not make sense ;)
<pixelou>
in fact I'm used to do imperative programming and I can't manage to do a fonction that fills an array whith a loop and then returns this array
<zorun>
then there is another, cleaner solution :)
<pixelou>
I hope so
<zorun>
what do you want to do exactly?
<pixelou>
I have a distribution of point and for each point I add the echo signal to the signal actually received by the microphone
<zorun>
which basically means taking the sum of two arrays, in your case?
<pixelou>
yes, in a way
<zorun>
working with lists is a much more natural way to do things in a functional language
<zorun>
I would do it that way:
<pixelou>
ok, I see
<zorun>
List.map2 (+) list1 list2
avsm has joined #ocaml
<pixelou>
so i need to build list2 before.... ok I'll try to modify my code
<hcarty>
pixelou: For reference, Arrays can be quite natural in OCaml too. With Batteries you get an equivalent Array.map2 function
<zorun>
I don't think there is a `map2' function for Array, but you can write it as well
<hcarty>
pixelou: You could compute the values from list2 on the fly, if that is simpler
<pixelou>
no I'll use a procomputed one it's possible in my case because i always use the same signal
<hcarty>
zorun, pixelou: My guess is that the stdlib lacks Array.map2 because Array.mapi provides a reasonable, if slightly less pretty, replacement for Array.mapN
<zorun>
hcarty: interesting, how do you build a map2 function from mapi?
Boscop_ has joined #ocaml
Boscop has quit [Ping timeout: 255 seconds]
mcclurmc_home has quit [Ping timeout: 255 seconds]
<zorun>
got it, something like "let map2 f a1 a2 = Array.mapi (fun i e -> f a2.(i) e) a1"
<zorun>
you're right, not so pretty
<hcarty>
zorun: Indeed. It's not terribly difficult, but it's not terribly readable either :-)
Boscop_ has quit [Ping timeout: 255 seconds]
Boscop has joined #ocaml
Boscop has quit [Read error: Connection reset by peer]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
ApeShot has joined #ocaml
<ApeShot>
Is it some peculiarity of my emacs setup or does the ocaml-mode with Tuareg indent `match` expressions incorrectly?
<ApeShot>
Each case is indented one level higher than the previous one
<ApeShot>
So a match expression tends to cruise off the edge of the screen pretty fast
<zorun>
which version of tuareg-mode?
<ApeShot>
The one in the ubuntu repos. Let me check the exact version
<zorun>
working fine with 2.0.4 here
<ApeShot>
Ok, I'll install from source - the repo is way out of date
<zorun>
and as far as I remember, this bug never showed up since I've started using tuareg-mode (a couple of years ago)
<ApeShot>
Well, hopefully it will fix itself when I update. I've been using emacs for years, but I've never really gotten into how to deal with indentation except at a very superficial level
nejimban has joined #ocaml
dnolen has joined #ocaml
ApeShot has quit [Remote host closed the connection]
lopex has quit []
jamii has joined #ocaml
ApeShot has joined #ocaml
<ApeShot>
Running the latest tuareg now, still getting the weird match/case indentation.
<ApeShot>
Running GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1)
<ApeShot>
of 2011-03-04 on palmer, modified by Debian
<zorun>
do you have a .emacs?
<ApeShot>
I have a .emacs.d with lots of sub scripts
<ApeShot>
Do you want the one specific one associated with ocaml?
<ApeShot>
I add the tuareg directory to the load path, require 'tuareg, configure the auto-mode-alist to do tuareg mode for ml files
<ApeShot>
And thats it
mjonsson has joined #ocaml
<ApeShot>
Ok, just loaded an emacs -q, so without any init files, added the tuareg directory, required tuareg-mode, set up the auto-mode list and opened an ml file, which went into tuareg mode, as you'd expect
<ApeShot>
It is still indenting match expressions incorrectly
<ApeShot>
All I can imagine is that its my version of emacs
<ApeShot>
Oh, I see
jamii has quit [Ping timeout: 276 seconds]
<ApeShot>
If you don't lead each line with | it indents incorrectly
<zorun>
*each* line? what do you mean?
<zorun>
oh, you mean the first one?
<ApeShot>
So you can write as legit ocaml match x with 10 -> "ten" | 11 -> "eleven" |...
<ApeShot>
But that will indent incorrectly
<ApeShot>
You have to say instead match x with | 10 -> "ten" <newline> | 11 -> "eleven" <newline> | ...
<ApeShot>
Each line after with should lead with the "|"
<ApeShot>
Rather than putting it on the previous line, as I was doing
<ApeShot>
My code compiles either way, but only indents correctly the latter
<zorun>
Actually, using a | even for the first line is considered a good practice
<ApeShot>
Why?
<zorun>
maybe some kind of symmetry
<ApeShot>
Interesting
<ApeShot>
Ok, well, thanks
<ApeShot>
Have a great one
ApeShot has quit [Remote host closed the connection]
<pixelou>
does anyone know why ocaml would say says "unused variable echo" about my function echo
<zorun>
because you don't use it, maybe?
<pixelou>
but it is not a variable
Smerdyakov has joined #ocaml
mcclurmc_home has joined #ocaml
<pixelou>
it's a function
<zorun>
pixelou: actually, it is the same thing for OCaml
<zsparks>
it is a variable with function type.
<pixelou>
ok sorry for question then
<zorun>
no problem
<ygrek>
it is a value to be precise
<pixelou>
anyway, when I call the function it fails to find it, I must have made some mistakes before
<pixelou>
thank you ygrek for this precision, I must admit I' m really dicovering ocaml
<pixelou>
and sorry for my poor english.... discover is not exact here, I should say finding out how ocaml works
lamawithonel_ has joined #ocaml
lamawithonel has quit [Ping timeout: 255 seconds]
mcclurmc_home has quit [Ping timeout: 255 seconds]
mcclurmc_home has joined #ocaml
mcclurmc_home has quit [Ping timeout: 255 seconds]