<andrewb>
It's heavy-going in parts, but bits of it are straightforwards
<yella>
how can I circumvent the 'this expression has type t but is here used with type t'-problem mentionned on the caml.inria.fr Q&A page
__DL__ has joined #ocaml
<Banana>
are you using the toplevel ?
<yella>
i got the error there,yes. but im only testing some functions in the toplevel.
<Banana>
if so, you defined a type t, then defined a function using type t, then changed type t then apply your function to something of the new type t.
<Banana>
so juste restart the toplevel and it should be fine.
<yella>
hm. so it shouldnt be a problem using a recursive function fun1, returning type t, and call fun1 in the recursive fun2 which also returns type t ?
<yella>
well I try, thanks
__DL__ has quit [Client Quit]
<yella>
I'd like to have a toplevel with history. arrow-up is so nice..
<Banana>
use ledit.
<Banana>
install ledit and just run "ledit ocaml"
<Banana>
(or use the tuareg emacs mode, to run ocaml within emacs).
<yella>
ledit is working, very nice.
<yella>
thanks
<Banana>
you can also ledit -h history.ml ocaml to keep track of what you typed in a file.
<yella>
is it possible to use/import interface files in the toplevel?
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
Lemmi1 has joined #ocaml
avlondono has joined #ocaml
Lemmih has quit [Read error: 110 (Connection timed out)]
Lemmi1 is now known as Lemmih
<andrewb>
yella: Why would you need to do that?
maihem has joined #ocaml
<lucifer>
is it possible to get this working (without using a loop):
<lucifer>
let rec j =
<lucifer>
let x = Random.int (length l) in
<lucifer>
if x = i then x else j
<lucifer>
(i know the list l is of length >= 2, but the compiler refuses to let me compile it (let rec j =
<lucifer>
let x = Random.int (length l) in
<lucifer>
(doh darn windows)
<lucifer>
i get "This kind of expression is not allowed as right-hand side of `let rec'"
<lucifer>
basically, i just want two unequal random ints..
<andrewb>
You can make j a function which takes a unit argument .. eg. let j () = ...
<andrewb>
(and you probably want not-equals rather than equals too)
<lucifer>
yeah saw that mistake just now :)
<andrewb>
;-)
<lucifer>
but 'let j ()' cannot recurse..
<andrewb>
let rec j () = let x = Random.int (List.length l) in if x <> i then x else j ();;
<lucifer>
ah :) thnx
* andrewb
ponders what "let rec" means for non-function bindings anyway
<lucifer>
any 'keep trying to obtain a value' variable.. f.i. let rec getchar = match keypressed with None -> getchar | Key(k) -> k;;
<lucifer>
not a very nice thing to do in functional languages :)
srv has quit [Read error: 113 (No route to host)]
<Banana>
or you can use it as a trick to define circular lists.
<Banana>
let rec l = 1::l
<Banana>
but you have to define their contents implicitely = let rec l = 1::2::3::4::l
<Banana>
you cannot add an element afterwards without breaking circularity.
srv has joined #ocaml
Shammah has quit ["ChatZilla 0.9.35 [Mozilla rv:1.5/20030925]"]
<Banana>
s/implicitely/explicitely/ of course.
<andrewb>
Cheers, I will play around with this later.
LordBrain has joined #ocaml
malte has joined #ocaml
<malte>
are all ocaml's libraries free as in speech?
<LordBrain>
i found out yesterday the nums library wasnt, but they're rewriting it.
yella has quit [Read error: 104 (Connection reset by peer)]
housetier has joined #ocaml
yella has joined #ocaml
zno has joined #ocaml
Axioplase has joined #ocaml
<Axioplase>
Hi!
<malte>
hi!
<Axioplase>
argh. i hate those Exception: Invalid_argument "Array.get"
wazze has joined #ocaml
<zno>
Axioplase: that would be much better than a segfault or bus error
<Axioplase>
zno: yep!
<Axioplase>
i m adding loads of try...with to get the guilty func....
<zno>
it's probably an off by 1 error no?
<Axioplase>
argh! i can't "try let foo=bar with XXX and try foo2=bar2 with YYY"
cjohnson has joined #ocaml
smkl has quit [Read error: 110 (Connection timed out)]
smklsmkl has joined #ocaml
<Axioplase>
let le_plus_a_droite x y = let i= ref 0 in
<Axioplase>
while (((x+ !i)<=(colonnes-1)) && (ecran.(x+ !i).(y)=ecran.(x).(y))) do i:=!i+1 done;
<Axioplase>
why doesn t it stop when x+!i goes after (colonnes-1) ?
<Dybbuk>
Wow, that's a whole lot of parens.
<Shadoko>
well it should...
<Shadoko>
why don't you use a for loop ?
<Axioplase>
because, i don't kown when it will stop. either because, we hit the right border (colonnes-1), either because value is different from the first one.
<Shadoko>
ah ok
<Axioplase>
but it always goes on, until i get an array.get exception.
<Meta>
Hi Shadoko ^_^
<Banana>
Axioplase: just insert a Printf.printf "x+i = %i ; colonnes = %i\n" (x+!i) (colonnes) ;in your do .. done statement.