<mbac>
what's the idiom in clojure for iterating a sequence without returning a value?
<mbac>
(e.g. i want to work with side-effects)
<mbac>
er, wait, wrong channel
<mbac>
:)
<thelema>
Enum.iter, in ocaml. :)
pheredhel has joined #ocaml
<sgnb>
thelema, edwin: it is in libfindlib-ocaml-dev
<thelema>
sgnb: of course; that makes sense
<sgnb>
actually, it could (should?) be in libfindlib-ocaml
<sgnb>
libfindlib-ocaml-dev is about using findlib as a library
<sgnb>
libfindlib-ocaml is about using findlib as a tool
<thelema>
not about using findlib for development?
<sgnb>
indeed
<sgnb>
ocaml-findlib/libfindlib-ocaml is about using findlib for development
<sgnb>
or let's say ocaml-findlib is about using findlib for development, and libfindlib-ocaml is its dependencies
<thelema>
ok, this makes sense too
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
ttamttam has joined #ocaml
ttamttam has quit [Remote host closed the connection]
oriba_ has joined #ocaml
avsm has joined #ocaml
<edwin>
sgnb: thanks, topfind works now
struktured has joined #ocaml
sebz has joined #ocaml
oriba_ has quit [Quit: oriba_]
avsm has quit [Ping timeout: 244 seconds]
EmmanuelOga has joined #ocaml
larhat has quit [Quit: Leaving.]
ygrek has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
thelema has quit [Remote host closed the connection]
thelema has joined #ocaml
ikaros has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
sepp2k1 has joined #ocaml
sepp2k has quit [Ping timeout: 244 seconds]
raichoo has joined #ocaml
ttamttam has joined #ocaml
ygrek has quit [Ping timeout: 248 seconds]
pheredhel has quit [Ping timeout: 252 seconds]
pheredhel has joined #ocaml
sepp2k1 has quit [Remote host closed the connection]
Anarchos has joined #ocaml
schme has quit [K-Lined]
ttamttam has quit [Remote host closed the connection]
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
Snark has quit [Quit: Quitte]
ttamttam has joined #ocaml
ttamttam has quit [Remote host closed the connection]
flapjackery has joined #ocaml
ijp has joined #ocaml
rwmjones_afk is now known as rwmjones
raichoo has quit [Quit: leaving]
Cyanure has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
ztfw has quit [Ping timeout: 252 seconds]
edwin has quit [Remote host closed the connection]
struktured has quit [Quit: Konversation terminated!]
struktured has joined #ocaml
Morphous has quit [Ping timeout: 258 seconds]
Morphous has joined #ocaml
roha has joined #ocaml
<roha>
hey, ive got a newbie question. i hope somebody could help me:
<roha>
ive tried to make a calculator in ocaml and i have multiple functions to parse a string etc.
<roha>
Now, ive got some functions that call each other and the compiler always complains about "unbound value block"
<thelema>
let rec foo = ... bar ... and bar = ... foo ...
<roha>
isnt it possible to define function headers at the beginning of an ml file?
<thelema>
no, there's no predeclarations in ocaml
<roha>
kind of like in C, so that i can call a function within a function that is defined after the former function,
<roha>
so if i want to use a function within a function i have to define it again within that same function?
<thelema>
no, you have to declare values in reverse dependency order
<thelema>
if you want to call [foo] from [bar], foo has to be defined first in the file
<thelema>
if you want to have mutually recursive functions, use the syntax from my first response
<roha>
ok thanks! ill use "...and..." then. :)
<thelema>
don't forget the 'rec' after the first 'let'
<roha>
in general, is it bad practise to write functions that depend on each other?
<thelema>
not at all.
<thelema>
since they're generally tightly coupled, they have to be defined together
<roha>
defined together as in defined in the same function through "...and..."?
<thelema>
defined simultaneously as part of one compound declaration
<roha>
sorry, how does a compound declaration look like? i cant seem to find it via google
<thelema>
let rec foo x = if x = 0 then 0 else 1 + bar (x-1) and bar x = x * foo (x-1)
avsm has joined #ocaml
<roha>
ok so if i have three functions: "foo", bar" and "foobar", that call each other in a way such that it is not possible to write them in a file without getting a "unbound value" error.
<roha>
the only way out of this would be to define the function again within another function via "...and..."?
<thelema>
you can - keep using more 'and's to connect them
<thelema>
not within the other function
<thelema>
let rec foo = ... and bar = ... and foobar = ...
<thelema>
this defines all three, and you can call any of the three from each other
<roha>
but bar and foobar are restricted to be used in foo right?
<thelema>
no, after this, all three are available
<thelema>
if you want bar and foobar only inside foo, it's:
<thelema>
let foo = ... let rec bar = ... and foobar = ... in
<thelema>
...
<thelema>
with this, bar and foobar are available only inside foo, but cannot call foo
<thelema>
if you really want to hide bar and foobar, and have all three mutually recursive:
<thelema>
let foo = let rec foo = ... and bar = ... and foobar = ... in foo
<roha>
ok just to be sure that i really got this right: i have multiple functions for my parser. the first declared function checks for a number in a given token-list, the function after that one in the ml file checks for parenthesis, the function after that one checks for addition/subtraction. and then the function that is called first, a function that tries to parse a whole expression.
<roha>
the problem is, that the function that checks for a number also calls the function that parses an expression, so i have multiple kind of independent functions that rely on each other.
<roha>
so the only way to solve this is through the things you've said?
<thelema>
it sounds like you're doing recursive descent parsing.
<roha>
exactly
<thelema>
The right way to do this in ocaml is with a lot of 'and's
<thelema>
defining the whole thing in one big recursive compound declaration
<roha>
aaaah ok!
<roha>
i think i got it, thanks so much!!
<thelema>
let rec num = ... and paren = ... and addsub = ... and expr = ...
<roha>
ok, now it starts to make sense. ill do it that way then, thanks!