cjeris changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
mikeX has quit ["leaving"]
pedro__ has joined #ocaml
_blackdog has quit [Read error: 60 (Operation timed out)]
_blackdog has joined #ocaml
rillig has quit [Read error: 110 (Connection timed out)]
pedro_soc has quit [Read error: 113 (No route to host)]
b00t has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
hsfb has joined #ocaml
<hsfb> hello everyone
<hsfb> once more i have run into simple problems...
<hsfb> now i need to apply some function f1 to each element of the list until the 4th position, and another function f2 to the rest
<hsfb> but List has no iteri
<hsfb> is there another way besides the truly awful for i = 0 to List.lenght... ?
<pango_> a recursive function ?
<hsfb> Another option would be to split the list in two halves, but I haven't figured how to do that with List.partition, since I am caring only about the position itself...
love-pingoo has quit ["Connection reset by pear"]
<pango_> it would not be very efficient either, because you can avoid scanning the end of the list
<hsfb> both of them wouldn't be efficient, right ?
<pango_> List.nth complexity is O(n), so you can immediately forget about the first solution, if that was what you had in mind
<hsfb> yes... it is not really a problem because the list will only have 8 elements (hehe) but i don't want to take the easy and ugly way
pantsd has quit [Read error: 110 (Connection timed out)]
<pango_> # let list_apply f1 f2 l =
<pango_> List.map2 (fun f x -> f x) [f1; f1; f1; f1; f2; f2; f2; f2] l ;;
<pango_> *g*
<hsfb> sry, the list will at *most* 8 elements
<pango_> damn :)
<hsfb> i can use that idea on another part of the code, though
<hsfb> look at how ugly this is:
<hsfb> if List.length !points = 8 then (
<hsfb> print_points [(List.nth !points 0); (List.nth !points 1); (List.nth !points 2); (List.nth !points 3)];
<hsfb> print_points [(List.nth !points 4); (List.nth !points 5); (List.nth !points 6); (List.nth !points 7)]);
<hsfb>
<hsfb> eww..
<pango_> well, for List.nth see above ;)
<hsfb> i will split the lists from the beginning... maybe it should never have been a single list...
<pango_> since I don't know what you're trying to achieve, I can't tell ;)
<hsfb> what is pango? that name is familiar from some sw...
<pango_> several things, but in my case it's a reference to an old video game (remake of pengu)
<hsfb> oh, my reference was from a graphics library i had to download another day ;)
JeffSmac has joined #ocaml
<JeffSmac> aH! interesting function
<pango_> hsfb: I wonder what you're trying to achieve, though...
<hsfb> i need to collect 8 points (two sets of 4) from the mouse and then draw some bezier curves
<hsfb> but before i have all 8 i already want to do an `x` where the user (myself only :P ) clicks
<hsfb> and on the first 4 i want one color, and on the last 4 another color, to differentiate amongst curves...
<hsfb> but what makes everything ugly is that i have to use global "variables" and i have to keep state because the functions are only called on mouse click, etc
<pango_> if they naturally flock in group of 4, it may be interesting to create arrays, or records, or tuples of 4 points (once the group is completed)
<hsfb> but on the mouse callback function, how do i know if i should add the new point into the first tuple or the second?
<hsfb> i have to check if the tuple/array is empty
<pango_> both have fixed size, so they can't be "empty"
<pango_> I'm thinking of using them once a group is completed only
<pango_> not replace lists altogether
<hsfb> humm
<pango_> (well, arrays could, if you keep around the index of the last point selected)
zeroslug has joined #ocaml
<JeffSmac> pango - thanks for showing me that website
<JeffSmac> btw I wrote what I think is an improved version of your function
<pango_> for 8 elements I don't make the effort of making the function tail-rec
<hsfb> :)
<JeffSmac> ya but, it's fun :)
<JeffSmac> and that is a very cool website. I can see myself using that in the future
<pango_> it's less readable, and may actually be slower
<pango_> but you didn't know it was for up to 8 elements :)
<JeffSmac> ya... for large lists it should be faster, or at least take less memory
<pango_> it has a bounded stack usage... that's what tail-rec is all about
<JeffSmac> I put a test in for if limit<0, but that I now see is unnecessary
<hsfb> are you talking to me or jeff ?
<pango_> JeffSmac: actually it's even incorrect, if limit < 0 it should return List.map fafter l
<JeffSmac> oh i see how the editing feature of that website works! THat's pretty slick http://nopaste.tshw.de/1178590120ab06d/1178590560/
<pango_> still, trying to keep maximum data sharing is a nice optimisation to keep in mind
benny_ has joined #ocaml
mbishop has quit ["brb"]
mbishop has joined #ocaml
benny has quit [Read error: 110 (Connection timed out)]
<hsfb> thanks pango
hsfb has quit ["ERC Version 5.2 stable pre-release (IRC client for Emacs)"]
JeffSmac has quit []
benny_ is now known as benny
Mr_Awesome has joined #ocaml
_blackdog has quit [Remote closed the connection]
pedro__ has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
mrvn has joined #ocaml
b00t has quit [Remote closed the connection]
pantsd has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
pion has quit [Read error: 110 (Connection timed out)]
pedro_soc has joined #ocaml
postalchris has joined #ocaml
sourcerror has quit [Read error: 148 (No route to host)]
sourcerror has joined #ocaml
postalchris has quit [Read error: 113 (No route to host)]
pantsd has quit ["Leaving."]
Mr_Awesome has quit ["...and the Awesome level drops"]
m3ga has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
pango_ has quit [Excess Flood]
pango_ has joined #ocaml
vital303 has joined #ocaml
love-pingoo has joined #ocaml
sourcerror has quit [Read error: 110 (Connection timed out)]
sourcerror has joined #ocaml
Demitar is now known as Demitar-
Demitar_ is now known as Demitar
zeroslug has left #ocaml []
joshcryer has quit [Client Quit]
bluestorm has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
dark_light has joined #ocaml
bluestorm has quit [Remote closed the connection]
sourcerror has quit [Read error: 113 (No route to host)]
_blackdog has joined #ocaml
love-pingoo has quit [Read error: 145 (Connection timed out)]
postalchris has joined #ocaml
love-pingoo has joined #ocaml
<kelaouchi> where can i get ocamlg ?
<flux> ocamlg?
<flux> oh, some mac-thingy
cjeris has joined #ocaml
cmeme has quit [Dead socket]
cmeme has joined #ocaml
ygrek has joined #ocaml
JeffSmac has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
Smerdyakov has joined #ocaml
JeffSmac has quit []
JeffSmac has joined #ocaml
LeCamarade has joined #ocaml
<LeCamarade> OCaml has no case structure?
<LeCamarade> Oh, it is the match,. Sorry.
mikeX has joined #ocaml
<kelaouchi> why do i not have ocamlbrowser on my system ?
<kelaouchi> do i need to install it ?
<pango_> maybe your ocaml package was not compiled with tk ? (or X libs...)
<JeffSmac> ocamlbrowser is nice but not necessary
<JeffSmac> I only use it when using large module libraries that I'm not familiar with, like labltk.
<JeffSmac> The ocaml documentation is better for the standard libraries, anyway.
vital303 has quit ["Leaving."]
<JeffSmac> Wow.... I'm really starting to appreciate TCL's introspection abilities.
<JeffSmac> I can't think of another language that lets you access a function's code after it's been interpreted/complied.
<JeffSmac> (function = proc)
<JeffSmac> metaocaml would allow this i imagine, actually
<pango_> Lisp
<pango_> no
<pango_> introspection and multistage compilation are totally different
<JeffSmac> I tihnk you could do it in ocaml if your ocaml program included the ocaml (bytecode) compiler, but hm...
<pango_> I don't think so either
JeffSmac has quit []
bluestorm has joined #ocaml
dark_ has joined #ocaml
dark_light has quit [Read error: 101 (Network is unreachable)]
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
ygrek has quit []
love-pingoo has quit ["go"]
kelaouchi has quit [Client Quit]
kelaouchi has joined #ocaml
kelaouchi has quit [Client Quit]
kelaouchi has joined #ocaml
joshcryer has joined #ocaml
noteventime has joined #ocaml
LeCamarade has quit [""ExitFailure 1000""]
<lucca> Not_found
Zzompp has left #ocaml []
twobitsprite has joined #ocaml
<twobitsprite> I don't see anything in the library for this, but is there a way to handle arbitrarily large numbers... or, at least "very large" numbers?
<twobitsprite> i.e. a number like he initially opened module
<twobitsprite> er
<twobitsprite> a number like 13256278887989457651018865901401704640
<bluestorm> hum
<bluestorm> Num ?
<twobitsprite> ahh... I must have skimmed over it looking for something like "bignum"... thanks
<twobitsprite> No implementations provided for the following modules: Num referenced from prime.cmx
<twobitsprite> I compiled with "ocamlopt -o foo foo.ml nums.cmxa"
<twobitsprite> and I try to "open Num" in my .ml
<pango_> the order matters
<twobitsprite> ahh, of course...
<pango_> put nums.cmxa first
<twobitsprite> thanks
<pango_> or use ocamlfind to take care of such details ;)
david_koontz has joined #ocaml
Mr_Awesome has joined #ocaml
noteventime has quit ["Leaving"]
bluestorm has quit ["Konversation terminated!"]
cjeris has quit [Read error: 104 (Connection reset by peer)]
david_koontz_ has joined #ocaml