melwtech35 has quit [Remote host closed the connection]
philtor has quit [Ping timeout: 245 seconds]
<orbitz>
is there any effort to allow me to specify the typ eof a function in the .ml file separate form teh definition?
ikaros has quit [Quit: Leave the magic to Houdini]
ulfdoz has quit [Ping timeout: 265 seconds]
melwtech35 has joined #ocaml
joewilliams is now known as joewilliams_away
avsm has quit [Quit: Leaving.]
philtor has joined #ocaml
snarkyboojum_ has joined #ocaml
lamawithonel_ has joined #ocaml
snarkyboojum has quit [Ping timeout: 255 seconds]
patronus has quit [Ping timeout: 255 seconds]
lamawithonel has quit [Ping timeout: 255 seconds]
kerneis has quit [Ping timeout: 255 seconds]
mal`` has quit [Ping timeout: 255 seconds]
patronus has joined #ocaml
kerneis has joined #ocaml
mal`` has joined #ocaml
<orbitz>
ohh i wish i coul dpush stuff into the front of a stream from outside it
Amorphous has quit [Ping timeout: 245 seconds]
Amorphous has joined #ocaml
seafood has quit [Quit: seafood]
vk0 has quit [Ping timeout: 265 seconds]
vk0 has joined #ocaml
seafood has joined #ocaml
seafood has quit [Quit: seafood]
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
philtor has quit [Ping timeout: 245 seconds]
<thelema>
orbitz: [let f : int -> int = fun x -> x+1] define type of function like this?
<flux>
or an embedded module
<flux>
(with signature)
ygrek_ has joined #ocaml
ygrek_ has quit [Ping timeout: 245 seconds]
ygrek has joined #ocaml
init1 has joined #ocaml
rwmjones is now known as rwmjones_afk
ulfdoz has joined #ocaml
rwmjones_afk is now known as rwmjones
mcclurmc has joined #ocaml
rwmjones is now known as rwmjones_afk
sohum has joined #ocaml
<sohum>
what's the syntax for when you want to pattern match something but also bind the un-patter-matched thing to a variable?
<adrien>
you mean for '_' ?
<julm>
just write a variable name for the un-patter-matched thing
<sohum>
adrien: that's one use case, yea
<flux>
I don't think I quite undestand what you mean :)
<adrien>
as julm said: instead of '_', name it
<sohum>
match t with Constructor1(a, b, c@Constructor2(d,e))
<flux>
(Constructor2 (d, e) as c) ?
<julm>
c@ ?
<sohum>
as
<flux>
@ is a haskell syntax for that
<sohum>
excellent, that workd
<sohum>
thank you!
<adrien>
grrrrr, I have local changes to lablgtk but I can't really propagate them through godi...
<julm>
keep it easy, it’s godimanche
<julm>
take*
<adrien>
:P
<sohum>
what's idiomatic ocaml for "modifying" the nth element of a list? i.e., if I want f [0;0;0;0;0] 4 1 = [0;0;0;0;1], how would I write f?
<flux>
the idiomatic way is to use arrays in such situations :)
<flux>
if that's not suitable I suppose I'd write a function to that for me
<julm>
let rec f lst nth ele = match lst with old::lst when nth = 0 -> ele::lst | old::lst -> old::f lst (pred nth) ele | _ -> raise Not_found;;
<sohum>
oh, I have arrays?
<julm>
but it is damn ugly
<flux>
mutable arrays no less
<sohum>
you'll have to forgive me, I'm still thinking in haskell :P
<flux>
using mutable arrays as immutable arrays might be less than optimal..
<sohum>
does ocaml have immutable arrays?
ikaros has joined #ocaml
<julm>
sohum: builtin, only records/tuples
<julm>
i.e. size must be known at compile time
<sohum>
julm: hmhm. thank you.
seafood has joined #ocaml
<adrien>
anyone proficient enough with makefiles to tell me if this will work? Z = ${Y} || ${Z}
<julm>
can't you just try it?
<adrien>
actually I found out it won't work because Y and Z (bah, should have been X) can be set to "yes", and I need the third one to be set to "yes" too, not just "true", "false", 0 or 1
Yoric has joined #ocaml
ztfw has joined #ocaml
ftrvxmtrx_ has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx_ has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
avsm has joined #ocaml
mcclurmc has quit [Ping timeout: 265 seconds]
ftrvxmtrx has quit [Ping timeout: 276 seconds]
ftrvxmtrx has joined #ocaml
mcclurmc has joined #ocaml
Snark has joined #ocaml
Smerdyakov has joined #ocaml
<adrien>
did I ever mention my hatred for make? no? well, now you know
<adrien>
at least I can have godi get the sources of lablgtk from a git repo now
pikachuyann has joined #ocaml
seafood has quit [Ping timeout: 265 seconds]
mcclurmc has quit [Ping timeout: 276 seconds]
<maskd>
adrien: why do you hate make?
<maskd>
in my experience autotools do most of the sucking
<adrien>
maskd: because I was using: a="yes"
<adrien>
and I had to use: a=yes
<adrien>
otherwise it failed the comparison to == "yes" later on
<adrien>
and the issues with indentation too
ftrvxmtrx_ has joined #ocaml
<ygrek>
and the absence of lazy initialization variables
seafood has joined #ocaml
mcclurmc has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
yezariaely has joined #ocaml
yezariaely has left #ocaml []
ulfdoz has joined #ocaml
seafood has quit [Quit: seafood]
<albacker>
what's the convention for comments (the ones beginning in " (*** " and the ones in " (** " ) ?
mcclurmc has quit [Ping timeout: 250 seconds]
ccasin has joined #ocaml
<gildor>
albacker: (** -> ocamldoc comment
<gildor>
(* simple comment
<gildor>
(*** don't know
<albacker>
gildor: ok thanks :)
metasyntax has quit [Quit: ♫ In our sky there is no limits, and masters we have none; heavy metal is the only one! ♫]
<albacker>
what's the best way for global variables? They will be assigned their fist values by fun1 and will be later changed recursively by fun2. What's the best way to do this? Let's say among of them there are some arrays. Should i declare everything as a ref array (outside all functions), and then change the values inside the functions?
<adrien>
well, if you want a mutable global variable, I don't see many other possibilities
<adrien>
if you have an array and only want to change its _contents_ (and not the array itself, meaning you keep the same length), arrays are mutable are therefore a possible choice
<albacker>
adrien: the problem is i don't know what the size will be before executing the first function (fun1 that is).
<adrien>
ref then
<rwmjones_afk>
you can also use a global struct (like a singleton) with a mutable field
<albacker>
isn't ref a struct with a mutable field itself/
<rwmjones_afk>
yup
rwmjones_afk is now known as rwmjones
ftrvxmtrx_ has quit [Quit: Leaving]
<albacker>
using Stack is it possible to know if an element is already inside?
<albacker>
i can see top, pop, push, create, length, etc. but i can't see a function that would return a boolean (like exists or something like this).
<albacker>
using iter i could do something that would raise an exception as soon as the found element is there, but i don't think this is an elegant solution.
<mfp>
albacker: if the elements are ordered you can use a (multi)set in addition to the stack
<mfp>
add to the set on push, remove the element on pop
joewilliams_away is now known as joewilliams
<mfp>
that'll give you O(log n) ops on the stack
<albacker>
i don't know if the sack is ordered.
<mfp>
the sack?
<albacker>
stack*
<albacker>
hehe :)
<mfp>
I'm referring to a total order being defined on the elements you're pushing to the stack
drunK has joined #ocaml
<mfp>
then you can use the stack to keep the insertion order, and an associated set to get a O(log n) mem operation
<albacker>
i don't see what you mean.
<albacker>
i just wanted to know if an elem was on the stack. the stack in fact is just a mutable list, i don't see why there isn't a Stack.exists since List.exists is avaliable.
<mfp>
are you OK with it being O(n) ?
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
<albacker>
mfp: well yes.
<mfp>
if so, Stack.iter will do, otherwise, you need something else (a multiset) to know if an element is in the stack in sublinear time
<albacker>
mfp: you mean i sort the stack on-the-fly?
<albacker>
each time i add an elem i put it in its 'right place' ?
<mfp>
What are the desired semantics of your data structure? Do you want to keep insertion order (FIFO), or is it OK to reorder elements?
<albacker>
i think i'll have to keep insertion order for the moment.
joewilliams has joined #ocaml
<mfp>
if O(n) complexity for mem is acceptable, a solution based on Stack.iter (inelegant as it is) should do, otherwise you need to supplement your data structure with a (multi)set
<mfp>
your code can be rewritten as let mem stack x = try Stack.iter (fun y -> if x = y then raise Exit); false with Exit -> true (no need to define and raise a 2nd exception, and you can use Pervasives.Exit)
joewilliams has quit [Client Quit]
joewilliams_away has joined #ocaml
<albacker>
mfp: i see what you mean in your 2nd phrase but i never seem to understand what you mean by '..you need to sipplement your data structure with a (multi)set'
<albacker>
how could i change the Stack structure without completely rewriting it (as in another .ml file)
<mfp>
Stack is, as you said, just a mutable list; it cannot support a [mem] operation in sublinear time directly
<mfp>
thus, if you want to have a, say, O(log n) operation, you can build your own data structure that uses both a stack (to keep the insertion order) and a set (for quick membership testing)
<albacker>
what's a set?
<mfp>
a set as returned by Set.Make(...)
<albacker>
i see a set is a binary tree in fact.
<mfp>
Set is implemented using AVL trees, but what matters is that it'll give you a O(log n) mem
<albacker>
i see, thanks for clarifying everything.
diml has quit [Ping timeout: 260 seconds]
<albacker>
:)
<mfp>
you can have something like let push t x = Stack.push x t.queue; t.s <- S.add x t.s
<mfp>
and then mem becomes just let mem t x = S.mem x t
<mfp>
oops S.mem x t.s
<mfp>
and then you have to remove the element from t.s when you pop
<mfp>
also, if an element can be pushed more than once, you need to use a multiset instead of a set
<albacker>
thanks.
<mfp>
np
<albacker>
it wont be pushed more than once.
boscop_ has joined #ocaml
boscop has quit [Ping timeout: 245 seconds]
<albacker>
i should become more familiar with modules and how to re-create new data structures (like this case for example).
diml has joined #ocaml
ikaros has quit [Ping timeout: 240 seconds]
ikaros has joined #ocaml
ftrvxmtrx_ has joined #ocaml
<adrien>
in godi, compiling against lablgtk2 pulls lablglade, lablrsvg and lablgtkspell (everything is set in the META), is it the same in other distributions? and btw, is this META standardized?
<kerneis>
adrien: yes, META in standardized (by ocamlfind)
<kerneis>
and any decent distribution should use ocamlfind (+META) too
<adrien>
kerneis: the issue is that there are _different_ METAs, lablgtk2's stock is actually too short so it's usually modified
<adrien>
could you pastebin your META for lablgtk2 so I can compare,
<thelema>
Just last night, I was toying with the idea of having emacs annotate (in a different color) function types on the same line as the function opening
<thelema>
(or maybe the next line if no room)
<thelema>
albacker: 1) remove all ;; from compiled code
<thelema>
2) if your function returns unit, put () at the end, not ;
<thelema>
ending with ; is likely your syntax error
<albacker>
i thin it was the ! before the i.
<thelema>
that too, i := !i + 1
<thelema>
array.(x) <- value
<thelema>
very different "assignment" operators
xl0 has quit [Ping timeout: 276 seconds]
<albacker>
thelema: so lines like that should be i := !i + 1 () and not with a ; at the end?
<thelema>
at the very end of your function
<thelema>
between "statements", ;
<thelema>
at the end, no ;
<thelema>
should be i := !i + 1;
<albacker>
ok
<albacker>
i see :)
<thelema>
but line 70 should drop the ;, or add () on line 71
<thelema>
also, since you can nest functions, you should consider making all your globals local to tarjan, and putting descente inside tarjan, above your primary iter_vertex
<albacker>
:)
khia0 has joined #ocaml
<albacker>
ok that's a good idea. thanks
<thelema>
this would get rid of a lot of ugliness, as you wouldn't need references to arrays.
<albacker>
true :)
<albacker>
i was asking about this before.
<adrien>
ah, great, I just discovered "man META"(5) (* I'm sure it'll be useful to many others :p *)
xl0 has joined #ocaml
ftrvxmtrx has quit [Remote host closed the connection]
<albacker>
File "kot3.ml", line 60, characters 17-25:
<albacker>
Error: This function is applied to too many arguments;
<albacker>
maybe you forgot a `;
<pikachuyann>
bonne semaine, à jeudi ou samedi ! / have a nice week, see you saturday
<julm>
salut pikachuyann
pikachuyann has quit [Quit: have a nice week !]
khia0 has quit [Quit: khia0]
<albacker>
damn i wrote it it compiles and i dont get the good result.
<gildor>
ocaml don't prevent bugs ;-)
BiD0rD has joined #ocaml
B1DOrD has joined #ocaml
BiDOrD has quit [Read error: Connection reset by peer]
BiD0rD has quit [Ping timeout: 240 seconds]
<thelema>
doesn't prevent all bugs
<adrien>
can anyone take a look at http://notk.org/~adrien/lablgtk2.META.html ? I wanted to make a more modular META for lablgtk2* (haven't looked at fedora's or debian's yet)
<adrien>
* I want to add a "react" subpackage to lablgtk2, obviously everyone doesn't want to pull it in, for each and every compilation
<adrien>
damn, the subpackages should have : archive(x) += "lablfoor.cm*", +=, not =
<adrien>
err, not, = is fine :P
lpereira has joined #ocaml
manveru has quit [Ping timeout: 265 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
ikaros has joined #ocaml
init1 has quit [Quit: Quitte]
<orbitz>
thelema: yeah, currently, i was wondering if that was a possible language improvement int he near future
manveru has joined #ocaml
<albacker>
what's the easiest way to debug ocaml programs?
<albacker>
is there a step-by-step executer or something like this (like gdb for C)
<adrien>
ocamldebug
<adrien>
best used within emacs afaik
<orbitz>
I do a lot of print_endline's
<albacker>
well print_endlines become tiring
<albacker>
especially when you have int to string and other conversions
<orbitz>
yeah it can be
<adrien>
Printf.printf :p
<orbitz>
Oleg has that sexy repr code thouhg
<orbitz>
which I should make use of
<adrien>
(with %! at the end of the format)
<orbitz>
whats %! do?
<adrien>
flushes output
<orbitz>
ah
<orbitz>
is it considere dbad form to do match (v1, v2) with .. rather htan nested matches/ I think i tmake sthe comparisons more obvious
<adrien>
extlib has a dump, so I guess batteries has it too
<kaustuv>
avsm: I do believe, though, that whatever ocaml does is conservative. It should be possible to cook up a case where some administrative tuples are created
<adrien>
anything depending on type-conv should do it too
ygrek has quit [Ping timeout: 245 seconds]
<adrien>
kaustuv: match (1, (2, 3) with ... ?
<avsm>
kaustuv: yeah, i'd just like to understand what that conservative limit is
<avsm>
no, it was just a tuple
<avsm>
although i wonder if one of the fields was a Block instead of a Long
<avsm>
ah, floats
<kaustuv>
btw, extlib's dump output can be difficult to interpret if you are not intimately familiar with how ocaml represents objects in memory.
<sohum>
how do I /use/ extlib? I installed libextlib-ocaml, but open ExtLib fails.
<kaustuv>
You need to #load "extLib.cma";;
<kaustuv>
If you have ocamlfind, then it's better to do #use "topfind" ;; #require "extlib" ;;
<sohum>
where, in the .ml file?
<sohum>
the # is causing a syntax error...
<orbitz>
#load is for toplevel
<kaustuv>
Sorry that was for the toplevel. For compiling, you need to give these options to the compiler: -I +extlib extLib.cma
<orbitz>
if you are compiling you need to specify it in the compile/link steps
<sohum>
ah, I see
<kaustuv>
That was for ocamlc. For ocamlopt: -I +extlib extLib.cmxa
<orbitz>
just use findlib
<orbitz>
I use findlib + OCamlMakefile for most things, life is simple
<kaustuv>
yes, findlib is Just Better (tm). ocamlfind ocamlc -package extlib foo.ml
rwmjones has joined #ocaml
<adrien>
-linkpkg
* adrien
keeps on forgetting it :-)
<kaustuv>
-linkpkg not needed for ocamlc. For ocamlopt, sure.
<adrien>
I've forgotten it so many times that it became a reflex, even when not needed =/
valross has joined #ocaml
<sohum>
okay, so I'm compiling with "ocamlfind ocamlc -package extlib -g -c core.ml", but it still can't find Std or ExtLib.Std
<kaustuv>
Oops, I think I'm wrong here. -linkpkg is always required for linking