zmdkrbou has quit [Read error: 110 (Connection timed out)]
asmanur has joined #ocaml
asmanur is now known as asmanur`branlett
asmanur`branlett is now known as asmanur
jderque has quit [Read error: 110 (Connection timed out)]
yminsky has joined #ocaml
zmdkrbou has joined #ocaml
Associat0r has joined #ocaml
jderque has joined #ocaml
Yoric[DT] has quit [Read error: 110 (Connection timed out)]
bluestorm has quit [Remote closed the connection]
bluestorm has joined #ocaml
gene9 has joined #ocaml
jderque has quit [Read error: 110 (Connection timed out)]
zmdkrbou has quit [Read error: 110 (Connection timed out)]
pango has quit [Remote closed the connection]
pango has joined #ocaml
nashdj has quit [Read error: 110 (Connection timed out)]
Morphous has joined #ocaml
gene9 has quit [Read error: 110 (Connection timed out)]
|Jedai| has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
_Jedai_ has joined #ocaml
jderque has joined #ocaml
jedai has quit [Read error: 110 (Connection timed out)]
asmanur has quit [Remote closed the connection]
|Jedai| has quit [Read error: 110 (Connection timed out)]
_Jedai_ has quit [Connection timed out]
asmanur has joined #ocaml
jderque has quit ["leaving"]
asmanur has quit [Remote closed the connection]
asmanur has joined #ocaml
yminsky has quit []
AxleLonghorn has joined #ocaml
<AxleLonghorn>
I need help with the module system in ocaml
<bluestorm>
what part ?
<AxleLonghorn>
I'm trying to use a two dimensional array using Bigarray
<AxleLonghorn>
and I'm pretty sure I'm creating it correctly, its just that I don't know what I need to be declaring in order to use the bigarray module
<maayhem>
I have some trouble understanding a particular case of exception handling in ocaml
<maayhem>
let x =
<maayhem>
try some code
<maayhem>
with x -> x
<maayhem>
end in
<hcarty>
AxleLonghorn: I had some confusion with that when starting with the Bigarray module
<AxleLonghorn>
k
<maayhem>
here, the x from "let x" and from "with x" are different right ?
<hcarty>
let terrain = Array2.create float64 c_layout 10 10;;
<AxleLonghorn>
thanks hcarty, it works now
<hcarty>
AxleLonghorn: You're quite welcome
<hcarty>
maayhem: "with x -> x" : those two 'x' refer to the same thing (the exception)
<maayhem>
sure but the toplevel x of "let x" is not the same x right ?
<hcarty>
maayhem: correct
<hcarty>
With "let foo = ... in", 'foo' is not visible in the ...
<hcarty>
With "let rec foo" it would be, but I /think/ something like you showed would still mask it
<bluestorm>
i think too
<bluestorm>
with the static scoping model
<bluestorm>
with x -> ... x is masked
<maayhem>
let x = try code with y -> y + 1
<maayhem>
in that example, when is exactly y bound in the environment ?
<maayhem>
y is somewhat what is returned by "code", even if y is an exception
yminsky has joined #ocaml
bluestorm has quit [Remote closed the connection]
bluestorm has joined #ocaml
<maayhem>
sorry, that's too much of a compiler question .. not really relevant I guess
<hcarty>
maayhem: y would be an exception type I think?
<bluestorm>
maayhem: only exceptions are bound to y
<bluestorm>
the one raised during "code" evaluation
<bluestorm>
and this is a pattern matching
<bluestorm>
you could do with _ -> ... and bind nothing
<bluestorm>
or with Failure failure_string -> ... | Exit -> ... , etc.
asmanur has quit [Read error: 110 (Connection timed out)]
buluca has quit [Read error: 113 (No route to host)]
jderque has joined #ocaml
Morphous is now known as Amorphous
zmdkrbou has joined #ocaml
<flux>
I've only read about scala (and most recently a rant on it linked from reddit), and its pattern matching is apparently slightly more advanced(?) - making the code more impenetrable
<flux>
apparently in scala (almost) such a pattern match (let rec x = ... in try .. with x -> ..) the latter x would match only if it matches the previous binding
<flux>
so you need to know which names are bind in a scope to know if a pattern match matches anything or exactly one value
<flux>
I personally prefer the ocaml way (although I haven't tried the scala way in practice)
<flux>
well, the one which specifically points out the issue :)
<bluestorm>
the fun thing wich such "hybrid" languages is that
<flux>
ah, middayc's url is the one I referred to
<bluestorm>
it points out the obvious benefits of functional programming to Java-accustomed developpers
<flux>
I've probably read the other ones too
<middayc>
def sum(l: List[int]): int = (0/:l){_+_}
<middayc>
you meant this code maybe?
<bluestorm>
and they're quite baffled, while functional users don't see what's new
<bluestorm>
i mean
<bluestorm>
last time they was a blog on reddit
<flux>
I didn't refer to that particular code
<flux>
I don't think there was any actual example of the issue
<bluestorm>
"waw, Scala has structural typing, it's so Great !"
<flux>
btw, I'd like to see that _ -syntax for ocaml too
<flux>
..been thinking that it'd be a nice way to study camlp4 developing..
<bluestorm>
flux: instead of (+) ?
<bluestorm>
hm
<flux>
bluestorm, instead of foo _ (42 + _)
<flux>
that is: not just for +
<flux>
or operators
<bluestorm>
i see
<bluestorm>
iirc Nemerle does that too
<flux>
for _very_ light (syntactic-wise) lambda functions
<flux>
actually I remember reading about scheme function 'cut' which does the same thing
<flux>
which lead me to think about having that in ocaml
<bluestorm>
hm
<ita>
looks like a solution in search of a problem
<bluestorm>
i guess that would be quite easy to write
<bluestorm>
as a camlp4 extension
<flux>
I wonder what would the separator be, though.. I'm thinking something parenthesis-like, but they are all taken, if not by ocaml then by some other extension ;)
<bluestorm>
i'm not sure _ is a good choice though
<bluestorm>
flux: hm
<bluestorm>
what about a keyword ?
<bluestorm>
separator cluttor is not always desirable
<flux>
if the syntax to express that is any long, it sort of defeats the purpose
<bluestorm>
hm
<bluestorm>
you're right
<flux>
_-syntax would help when currying doesn't work (arguments in wrong order)
<flux>
would syntax like \{} would be possible with camlp4?
<flux>
\{_ / 5}
<bluestorm>
i guess so
<bluestorm>
\ sounds "lambda"
<mbishop>
that's nasty syntax, even for ocaml :P
<ita>
\_o<
<mbishop>
it's a duck!
<ita>
mbishop: :-)
<bluestorm>
*PAN*
<bluestorm>
what the right answer
<bluestorm>
-t+s
<ita>
\_o<~~
<ita>
en c we have this gem: while (0 <-- c) do_something();
<flux>
that could be used as a duck-casting operator
<bluestorm>
\_o< foo _ (42 + _) >o_/ ?
<ita>
bluestorm: haha
<flux>
actually even a version that supported a single _ would be suitable for me, but if you can put them inside each other, you get (a slightly different) support for multiple blanks
<flux>
hm, actually no, it wouldn't be the same
<bluestorm>
i don't think supporting numerous blanks is significantly harder than supporting one
<ita>
something much more useful is the # for commenting out single lines
<flux>
you need to make sure you fill in the blanks in the order they are visually in the code
* ita
hacked his twt version to have it
<flux>
nah, editor can do that for me.. atleast it could if I instructed it to :)
<bluestorm>
hm ita
<ita>
bluestorm: yes ?
<bluestorm>
C-; does that
<flux>
(add (* and closing *) to the end, and remove them)
<bluestorm>
easily
<flux>
it almost does that?
<flux>
it doesn't put existing stuff inside comments
middayc has quit [Read error: 104 (Connection reset by peer)]
<flux>
which I'm guessing what ita wants, no?
<flux>
actually you refer to M-;, don't you?
<bluestorm>
yes, sorry
<flux>
also M-; neatly lines the comments up :)
<bluestorm>
hm
<bluestorm>
M-; doesn't actually do that by default
<bluestorm>
as flux said, it adds a (* *) at the end of the line
<bluestorm>
but i'm quite sure it's easy to do
<flux>
actually I didn't mean it that way
<flux>
I was thinking of a feature what would insert (* to the cursor point and then append *) to the end of the line
<bluestorm>
(even *my* poor emacs-fu could do that with a little documentation work, i guess)
<flux>
and a binding to remove the comment from the current line
<flux>
not too tough to press C-k, M-;, C-y, though, but it messes up the layout compared to simply pressing #
<ita>
flux: if you do that, what happens if you remove the end of line ? the text is not commented
<flux>
ita, you mean combine two lines?
* ita
wants the real sh-like # for comments
<ita>
flux: yes
<flux>
perhaps the editor can tag such comments with (*# adsf *) and automatically do the right thing.. ;-)
<flux>
#-comments are occasionally nice, but otoh I think it's a bit overkill to require a language extension to compile code because it uses extended comments..
<ita>
that's the preprocessor's job
middayc has joined #ocaml
middayc has quit []
AxleLonghorn has left #ocaml []
jderque has quit ["leaving"]
middayc has joined #ocaml
mordaunt has joined #ocaml
ttamttam has joined #ocaml
asmanur has quit [Remote closed the connection]
middayc has quit []
bluestorm has quit [Remote closed the connection]
ttamttam has left #ocaml []
mordaunt has quit [Read error: 104 (Connection reset by peer)]
yminsky_ has joined #ocaml
yminsky_ has quit [Client Quit]
<jdavis_>
Is there a way to write a function that does something like "fun tuple n x -> ..." such that it set's the Nth element in the tuple to x?
<jdavis_>
The tuple is a constant 2 element tuple.
<pango>
tuples are immutable, you must create a new tuple
<jdavis_>
I was unclear, I mean a function that returns a new tuple with element n set to x and the other elements the same
<pango>
there's no such type as 'tuples of any length', so you need to create a function for each length
<jdavis_>
That's fine with me
<jdavis_>
My tuples are only two elements, so the domain of n is only {0,1}
<mlasson>
(fun (a,b) -> function 0 -> (fun x -> (x,b)) | 1 -> (fun x -> (a,x)) | _ -> failwith "arg") ?
<pango>
yes, for example
<jdavis_>
Oh, ok, that makes sense. I am still learning so using matching is not something that occurs to me as a solution right away. Thanks!
maayhem has quit [Remote closed the connection]
yminsky_ has joined #ocaml
<mlasson>
let f (a,b) n x = match n with 0 -> (x,b) | 1 -> (a,x) | _ -> failwith "arg" ? It may be more "beginner-proof" (it hasn't exactly the same behavior)
<jdavis_>
I was just looking up the exact difference between function and fun. I mentally translated the first example into the second... what's the difference?
<pango>
let f = function ... <=> let f x = match x with ... and let f x y = ... <=> let f = fun x -> fun y -> ...
* jdavis_
is thinking...
hordf has quit ["Bye"]
<pango>
(still looking for fun and function in the manual... :/ )
<pango>
so function does pattern matching, while fun can accepts several parameters
<pango>
so, let f x y = ... <=> let f = fun x y -> ...
<jdavis_>
Oh, I see.
<pango>
mmmh both accept guards, but I wonder how to use it with 'fun' without triggering a warning...
<jdavis_>
and so with function it would be: let f x y = ... <=> let f = function x -> function y -> ...
<pango>
correct
yminsky_ has quit []
<jdavis_>
What exactly does "and" do? I am having a problem where a function name is not in scope even though the definitions are linked by an "and". If I change the "and" to "... in let ..." it works.
<pango>
simultaneous definitions
<pango>
unless you start the simultaneous definitions with 'let rec', they don't "see" each others
<jdavis_>
Oh.. that makes sense.
<jdavis_>
but this works for some reason: let a n = if n = 0 then 0 else (b (n-1)) and b n = if n=0 then 0 else (a (n-1));;
<jdavis_>
There's no "rec" in the definition, but for some reason that works.
<pango>
if you're experimenting in the toplevel, they're probably using previous definitions of a and b ;)
<jdavis_>
oh, haha
<jdavis_>
Whew, I finally implemented the algorithm that I've been working on. This is the most fun I've had programming in a long time! Ocaml is a great language.
<diosmalo08>
France vs Netherland in the football, xDDD
<pango>
but it's not cross-platform
<diosmalo08>
jdavis_, yes, they are similar unless OO, but both are from functional programming.
<jdavis_>
ocaml seems like a pretty decent platform though... it has a debugger, build tools, lots of libraries. That's why I chose to learn ocaml first is it seemed most practical.