<sc30317>
there is some stuff between topfunction and finish btw
<sc30317>
derdon, what do you mean?
<sc30317>
what do you get?
<sc30317>
a cookie :D
<derdon>
wohho! I get a cookie :)
<sc30317>
for sure
<sc30317>
om nom nom
<derdon>
and your problem is how to quit this recursive function?
<sc30317>
exactly
<derdon>
is the attempt in line 16 or 19? or are your attempts not visible?
<sc30317>
I am talking about the attempt in line 4
<sc30317>
if is_finished || count = maxiterations then w_current
<sc30317>
if it gets to w_current, I just want it to exit the loop
<sc30317>
sort of ~ to a break in C
<derdon>
call another function, exit the whole script, raise an exception, ...
<derdon>
do whatever you want there ;)
<sc30317>
derdon, that is what I am not sure of?
<derdon>
sc30317: what should happen after leaving the function?
<sc30317>
go back to the ocaml prompt
<derdon>
you know that every function has a return value?
<sc30317>
yes
<derdon>
then you could return the equivalent form of NULL (forgot its name)
<derdon>
but raising an exception is much better, I think
<derdon>
or return something more sensible
<sc30317>
why would raising an exception be better?
<sc30317>
and how would I do so in this case
SEcki has joined #ocaml
SEcki has quit [Quit: cu]
<derdon>
sc30317: because it's better style
<derdon>
sc30317: remember: we love exceptions :)
<sc30317>
this is true
<sc30317>
how would I raise an exception in this case?
<sc30317>
and what exception should I raise?
<derdon>
sc30317: like you do it in any other case
<sc30317>
derdon, how would I do it in any case?
tmaedaZ is now known as tmaeda
<derdon>
sc30317: you have to ask yourself the question: "Why is the function terminated?". then you know the reason and therefore the name of your exception
<derdon>
sc30317: ``raise My_exception``
<sc30317>
the function is terminated because is_finished is finished
<derdon>
and why has is_finished finished?
<sc30317>
because if_finished is true or count = maxiterations
<sc30317>
but how can I translate that to an exception
<sc30317>
I guess that is the question I am asking derdon
<derdon>
``Maximum_recursion_depth``
<derdon>
``Maximum_iterations`` is better
<derdon>
hm, don't know. recursive functions don't have iterations
<derdon>
so ``Maximum_recursion_limit`` is a good name
<sc30317>
ok so I would say
<sc30317>
if is_finished || count = maxiterations then raise Maximum_recursion_limit
<derdon>
yes
<sc30317>
and outside the function I would put Exception Maximum_recursion_limit w_current?
<derdon>
but that is information which is only for developers relevant/interesting
<sc30317>
this is true
<sc30317>
derdon, so what are you telling me to do?
<sc30317>
*telling me i should do?
<derdon>
outside the function, you write ``exception Maximum_recursion_limit``
<sc30317>
yea
<sc30317>
and what else with it?
<derdon>
if you had a better name, you could write something like ``raise Invalid_vector``
<sc30317>
ok
<derdon>
but if cannot explain why your function terminates, you have the next problem
<sc30317>
I can
<sc30317>
because it gets either to maxiterations or finished is true
<derdon>
and when? and why?
<sc30317>
when?
<sc30317>
when the loop has gone maxiterations times
<sc30317>
or when the finished function that is called is true
krankkat` has quit [Remote host closed the connection]
<derdon>
you have to think abstracter
hcarty_ has joined #ocaml
<sc30317>
abstracter?
<sc30317>
hahah
<sc30317>
ok
svenl has quit [Disconnected by services]
svenl_ has joined #ocaml
<sc30317>
compare_vc_current_class is returned false
Asmadeus_ has joined #ocaml
mutewit has quit [Ping timeout: 260 seconds]
hcarty has quit [Ping timeout: 260 seconds]
quelqun_dautre has quit [Ping timeout: 260 seconds]
Asmadeus has quit [Remote host closed the connection]
quelqun_dautre has joined #ocaml
brendan has quit [Ping timeout: 260 seconds]
mutewit has joined #ocaml
haelix has joined #ocaml
haelix_ has quit [Remote host closed the connection]
<sc30317>
derdon, is that abstracter enough?
brendan has joined #ocaml
<derdon>
sc30317: no
<derdon>
sc30317: imagine you don't know the code of your function. all you know is the signature
<sc30317>
ok
<derdon>
your function compares two vectors, right?
<sc30317>
correct
<sc30317>
which are 2 Lists
<derdon>
and if the user does something wrong applying the function, an exception is raised
<sc30317>
that is true
<sc30317>
but it would just go right back into the function
<sc30317>
I think?
<derdon>
so the question is now: what does the user do to get an exception?
<sc30317>
error
<derdon>
???
<derdon>
the user does "error" to get an exception? are you kidding?
<sc30317>
no they raise an error
<sc30317>
by doing something incorrectly
<derdon>
right
<sc30317>
ok
<sc30317>
so I would have to do something incorrectly
tmaeda has quit [Ping timeout: 245 seconds]
<derdon>
and what does the user do to make this function break the recursion?
<sc30317>
get to is_finished or maxiterations
<derdon>
no, the user doesn't get there
<derdon>
what does the user do?
<sc30317>
inputs the parameters into the function
<derdon>
right
<derdon>
and is there anything wrong about one of the parameters when the function is terminated?
tmaeda has joined #ocaml
<sc30317>
yes
<sc30317>
they are different
<derdon>
different than what?
<sc30317>
different then their initial values
ofaurax_ has quit [Quit: Leaving]
<derdon>
so this is the asnwer! bing-bing-bing =)
<sc30317>
I have no idea how that ties into the raise Maximum_recursion_limit?
<derdon>
you said the reason for terminating your recursive function is that the user applied the function with paramters which are different from their initial values
<derdon>
so you can rename the exception now to a better name
<sc30317>
so name the exception finish_different?
<derdon>
no
<sc30317>
finish_(one of the function parameters)?
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
pimmhogeling has quit [Ping timeout: 245 seconds]
boscop_ has joined #ocaml
boscop has quit [Ping timeout: 264 seconds]
tmaeda has quit [Ping timeout: 240 seconds]
boscop_ has left #ocaml []
boscop has joined #ocaml
tmaeda has joined #ocaml
myu2 has joined #ocaml
joewilliams is now known as joewilliams_away
myu2 has quit [Ping timeout: 260 seconds]
sc30317 has quit [Quit: Leaving]
tmaeda is now known as tmaedaZ
asurai has joined #ocaml
struktured has quit [Ping timeout: 264 seconds]
struktured has joined #ocaml
drk-sd has quit [Quit: {'EXIT', drk-sd, "bye"}]
myu2 has joined #ocaml
philtor has joined #ocaml
philtor has quit [Ping timeout: 276 seconds]
_unK has quit [Remote host closed the connection]
joewilliams_away is now known as joewilliams
asurai has quit [Remote host closed the connection]
asurai has joined #ocaml
tmaedaZ is now known as tmaeda
bzzbzz has quit [Quit: leaving]
enthymeme has joined #ocaml
jeddhaberstro has quit [Quit: jeddhaberstro]
tmaeda is now known as tmaedaZ
thrasibule has quit [Ping timeout: 248 seconds]
joewilliams is now known as joewilliams_away
tmaedaZ is now known as tmaeda
yakischloba has joined #ocaml
tmaeda is now known as tmaedaZ
valross has quit [Ping timeout: 260 seconds]
valross has joined #ocaml
<eldragon>
hi guys, is practical to have one billion of objects in memory?
<orbitz>
eldragon: depends on a number of factors
avsm1 has joined #ocaml
avsm has quit [Ping timeout: 264 seconds]
avsm1 has quit [Client Quit]
asurai_ has joined #ocaml
asurai_ has quit [Client Quit]
asurai has quit [Ping timeout: 245 seconds]
jcaose has joined #ocaml
Submarine has joined #ocaml
ulfdoz has joined #ocaml
LionMadeOfLions has quit [Ping timeout: 248 seconds]
LionMadeOfLions has joined #ocaml
<Camarade_Tux>
morning =)
<Camarade_Tux>
hcarty_: hmmm, here is your prize for the week's dirtiest work-around :P
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
yakischloba has quit [Quit: Leaving.]
drewbert has joined #ocaml
<drewbert>
is there a way I can get the line number of a stack overflow?
<flux>
eldragon, well, for one, it would take more than 8 gigabytes (on a 64-bit platform), although probably a lot more because I don't know what the other overhead of ocaml objects are
<flux>
eldragon, another issue is that gc might take a lot of time in that situation
<flux>
(and you don't want to really start paging a gc'd process onto a disk)
<drewbert>
so no?
<flux>
try it :)
<flux>
depends on your resources and needs I guess
<drewbert>
here's perhaps an easier question
<drewbert>
http://pastebin.com/9n8ZwyCD <-- what do you think is causing the stack overflow in that? where is the infinite loop
<drewbert>
this is my first functional programming project
<drewbert>
it has been painful at best
<ulfdoz>
huh, source code documentation. You are not a developer! ;)
<flux>
drewbert, btw, you might find this construct useful in the is_equal-function: match aa, ab with | [], [] -> true | [], _ | _, [] -> false ..
<Camarade_Tux>
and a program of /win 1
<Camarade_Tux>
bleh
<Camarade_Tux>
leaving =)
<ulfdoz>
My first guess: add_to_paths produces too many paths, which will result in a big stack with solve_good invocations.
<flux>
nothing in the source seems to be an infinite loop, though
<flux>
so perhaps it's an O(n^2)-kind of issue
<flux>
(I took a look at each function and checked that they called themselves only with the input reduced by one element)
<drewbert>
and everything but solve_good does that
<flux>
(well, unless you call solve_board with negative n)
<Camarade_Tux>
wouldn't ocamldebug say where it's doing too many recursions?
<flux>
drewbert, does it work for small values of n?
<ulfdoz>
I'd also try to optimize add_to_paths with some implementation of set instead of working on the list.
<drewbert>
flux: conks out at around 12
<drewbert>
with an input size of 8
<flux>
drewbert, how many paths do you have at that point?
<flux>
drewbert, because operator @ consumes a lot of stack
<drewbert>
<= 4^12
<flux>
drewbert, if order doesn't matter, perhaps you want to use List.rev_append in place of it
<drewbert>
actually
<drewbert>
3^12
<flux>
drewbert, if order does matter, use List.rev_append anyway, but use List.rev in addition to that
<drewbert>
flux: I'm only allowed to use things that are in pervasives.
<flux>
drewbert, well, implementing them shouldn't be too hard
<flux>
drewbert, actually you might want want to change add_to_paths to use an accumulator parameter to remuve the concatenation altogether
<drewbert>
that uses less memory? I'll try it.. Get some fold action going here.
<drewbert>
on another note, is there an obvious better way of solving this problem?
<flux>
I think determining that would need some thinking about the problem. too early on vacation for me to do that, sorry ;).
jcaose has quit [Ping timeout: 258 seconds]
<drewbert>
that's chill. I respect the vacation time.
<drewbert>
My brain is letting me down.
<drewbert>
I should be able to do this.
<drewbert>
Just too accustomed to imperitive programming.
Sgeo has joined #ocaml
<Sgeo>
Are there any OCaml tutorials for Haskell users?
avsm has joined #ocaml
ttamttam has joined #ocaml
enthymeme has quit [Quit: g'night freenode]
o^_^o has joined #ocaml
ulfdoz has quit [Ping timeout: 260 seconds]
oc13 has joined #ocaml
myu2 has quit [Remote host closed the connection]
Submarine has quit [Ping timeout: 264 seconds]
myu2 has joined #ocaml
avsm has quit [Quit: Leaving.]
Yoric has joined #ocaml
slash_ has joined #ocaml
pimmhogeling has joined #ocaml
ikaros has joined #ocaml
eldragon has quit [Read error: Connection reset by peer]
eldragon has joined #ocaml
Asmadeus_ is now known as Asmadeus
f[x] has quit [Quit: Leaving]
f[x] has joined #ocaml
EricFisher has joined #ocaml
barismetin has joined #ocaml
barismetin has quit [Changing host]
barismetin has joined #ocaml
EricFisher has left #ocaml []
valross has quit [Quit: Ex-Chat]
Yoric has quit [Quit: Yoric]
o^_^o has left #ocaml []
f[x] has quit [Ping timeout: 240 seconds]
f[x] has joined #ocaml
oc13 has quit [Ping timeout: 240 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
spearalot has joined #ocaml
derdon has joined #ocaml
_andre has joined #ocaml
eldragon has quit [Read error: Connection reset by peer]
spearalot has quit [Quit: Computer has gone to sleep]
eldragon has joined #ocaml
myu2 has quit [Remote host closed the connection]
spearalot has joined #ocaml
eldragon has quit [Read error: Connection reset by peer]
eldragon has joined #ocaml
Shoggoth has joined #ocaml
Shoggoth has quit [Client Quit]
derdon has quit [Quit: derdon]
tmaedaZ is now known as tmaeda
munga has quit [Remote host closed the connection]
derdon has joined #ocaml
smimou has quit [Ping timeout: 246 seconds]
smimou has joined #ocaml
bzzbzz has joined #ocaml
slash_ has quit [Quit: Lost terminal]
rwmjones has quit [Ping timeout: 245 seconds]
_unK has joined #ocaml
smimou has quit [Ping timeout: 276 seconds]
pimmhogeling has quit [Ping timeout: 245 seconds]
smimou has joined #ocaml
Submarine has joined #ocaml
Yoric has joined #ocaml
<Camarade_Tux>
I'm trying to pass -rectypes to ocaml with ocamlbuild, afaict, I have to call 'ocamlbuild -cflags -rectypes', but I don't see how I can put that in my _tags file
<Camarade_Tux>
doesn't look like there's anything to add '-cflag(s) *'
<f[x]>
ocamlbuild -documentation | grep rectypes
<Camarade_Tux>
ah nice one, I didn't know that
<Camarade_Tux>
looks like I'm stuck =)
joewilliams_away is now known as joewilliams
spearalot has quit [Quit: -arividerchi]
rwmjones has joined #ocaml
pimmhogeling has joined #ocaml
lokydor has joined #ocaml
yakischloba has joined #ocaml
lokydor_ has joined #ocaml
lokydor_ has quit [Client Quit]
bzzbzz has quit [Quit: leaving]
<Sgeo>
:t length
<Sgeo>
oops
bzzbzz has joined #ocaml
bzzbzz has quit [Quit: leaving]
_unK has quit [Remote host closed the connection]
bzzbzz has joined #ocaml
gabrielrf has joined #ocaml
gabrielrf has left #ocaml []
ttamttam has quit [Quit: Leaving.]
_unK has joined #ocaml
oc13 has joined #ocaml
bzzbzz has quit [Quit: leaving]
bzzbzz has joined #ocaml
<derdon>
how do I write signatures for classes? I had some attempts but they fail because of syntax errors
<flux>
derdon, try ocamlc -i foo.ml
<flux>
..where foo.ml is a file containing classes
<derdon>
flux: not foo.mli ?
<derdon>
okay
<flux>
derdon, ocamlc -i is a command to transform an implementation into a signature
<derdon>
ah, cool
krankkatze has joined #ocaml
ttamttam has joined #ocaml
lokydor has quit [Ping timeout: 258 seconds]
<derdon>
what does this mean: "The method connect has type string -> ('a -> 'b) -> 'a -> 'b where 'b is unbound"
ikaros has joined #ocaml
<mrvn>
derdon: that you have a polymorphic method where you didn't specify it as such
<mrvn>
derdon: You have a ['a] foo kind of class, right?
<derdon>
mrvn: hm, I am used to duck typing
<derdon>
mrvn: no, there is no 'a in the class definition
<mrvn>
Hmm, then 'a is probably unbound as well.
<mrvn>
Try specifying a type for the method as 'b. string -> ('a -> 'b) -> 'a -> 'b
<derdon>
mrvn: the method connect should be of type ``string -> (a -> b) -> string -> unit``
<mrvn>
derdon: can't be ('a -> 'b). The callback must have some fixed type
<mrvn>
If the callbacks were ('a -> 'b) then how would you ever call them?
Associat0r has joined #ocaml
<derdon>
mrvn: well, every callback receives one argument
<derdon>
which is a string
<derdon>
and the return value is unit
<derdon>
oh, talking and thinking helps :)
<flux>
wouldn't that be (string -> unit) then?
<mrvn>
derdon: So (string -> unit). You can do that.
<derdon>
mrvn: yes, talking about the problem helps a lot :)
<derdon>
flux: yes
<flux>
derdon, btw, you may find that you don't need to write so many type annotations if you write a bit more code
<mrvn>
derdon: as soon as you write the run method properly it should infere that
<flux>
derdon, at present ocaml cannot infer those types, because you don't actually use them anyhwere. you may need to annotate something, though.
<derdon>
flux: okay
<derdon>
ocaml has to read my mind
<flux>
atleast for the reader.. for example I might write: val mutable callbacks : (string -> unit) list = [] instead of val mutable callbacks = []
<flux>
I dare say it's easier to follow the former
<derdon>
what's the difference between ``val foo : ...`` and ``type foo = ...``?
<mrvn>
derdon: val creates a place in the object where the value is stored.
<derdon>
hm, I have just noticed that I don't really know what I want to do
<flux>
:)
<derdon>
mrvn: and ``let foo = ...`` is for *.mli files?
<flux>
derdon, you seem to be confused :)
<flux>
let foo = xx is a value binding
<derdon>
flux: I *am* confused!
<flux>
type foo = barbar is a type definition
<flux>
they are quite different
<flux>
val bar : baz is a value declaration (for a type signature)
<derdon>
ah, now I remember. thanks, flux
<flux>
but I'll be off to make some food
<derdon>
enjoy your meal!
<Camarade_Tux>
hcarty_: tried the toplevel with lwt?
hcarty_ has quit [Ping timeout: 258 seconds]
<Camarade_Tux>
gasp ^^
Submarine has quit [Quit: Leaving]
<Camarade_Tux>
thelema: I see batteries has a "toplevel.top" executable, problem is lwt has one with the same name, wouldn't it be nice to change the names?
ikaros has quit [Quit: Leave the magic to Houdini]
<thelema>
Camarade_Tux: the toplevel.top is deprecated and will likely get removed when someone gets around to it.
<thelema>
that toplevel isn't installed or used. I'm surprised it's still in the tree.
<Camarade_Tux>
thelema: godi, but with batteries 2009090x, I thought I had almost the latest available
<Camarade_Tux>
well, it is the latest available on godi...
<thelema>
ah, yes. the latest available on godi. I still need someone to godify the latest batteries
itewsh has joined #ocaml
<derdon>
ocaml is like a drum set: it's fun even if you're a noob :)
Yoric has quit [Quit: Yoric]
<Camarade_Tux>
^^
<thelema>
I agree.
barismetin has quit [Remote host closed the connection]
ReachingFarr has joined #ocaml
<ReachingFarr>
I remember reading somewhere about being able to turn patterns on and off during lexing using ocamllex, but I can't find the reference again. Anyone know what this might have been talking about?
tmaeda has quit [Ping timeout: 260 seconds]
SEcki has joined #ocaml
Submarine has joined #ocaml
tmaeda has joined #ocaml
ulfdoz has joined #ocaml
joewilliams is now known as joewilliams_away
tmaeda is now known as tmaedaZ
Yoric has joined #ocaml
enthymeme has joined #ocaml
ikaros has joined #ocaml
drk-sd has joined #ocaml
ygrek has joined #ocaml
jonafan_ has joined #ocaml
rwmjones has quit [Ping timeout: 245 seconds]
jonafan has quit [Ping timeout: 276 seconds]
CcSsNET has joined #ocaml
rwmjones has joined #ocaml
Associat0r has quit [Quit: Associat0r]
pimmhogeling has quit [Remote host closed the connection]
drunK has joined #ocaml
_unK has quit [Read error: Operation timed out]
Submarine has quit [Quit: Leaving]
tmaedaZ has quit [Ping timeout: 260 seconds]
tmaedaZ has joined #ocaml
jeddhaberstro has joined #ocaml
drunK is now known as _unK
_unK has quit [Quit: Konversation terminated!]
_unK has joined #ocaml
clog has joined #ocaml
_andre has quit [Quit: *puff*]
slash_ has joined #ocaml
avsm has joined #ocaml
jimmyb2187 has left #ocaml []
ttamttam has quit [Quit: Leaving.]
Tianon has quit [Remote host closed the connection]
ofaurax__ has joined #ocaml
CcSsNET has quit [Ping timeout: 248 seconds]
yakischloba has quit [Read error: Connection reset by peer]
yakischloba has joined #ocaml
ReachingFarr has quit [Quit: Leaving.]
thieusoai has joined #ocaml
ulfdoz has quit [Ping timeout: 264 seconds]
ofaurax__ has quit [Quit: Leaving]
boscop has quit []
oc13 has quit [Ping timeout: 245 seconds]
boscop has joined #ocaml
CcSsNET has joined #ocaml
jonafan_ is now known as jonafan
matthieu has joined #ocaml
maattd has quit [Ping timeout: 276 seconds]
slash_ has quit [Quit: Lost terminal]
MrEvil has joined #ocaml
rwmjones has quit [Ping timeout: 245 seconds]
matthieu has quit [Remote host closed the connection]
rwmjones has joined #ocaml
CcSsNET has quit [Ping timeout: 245 seconds]
Yoric has quit [Quit: Yoric]
CcSsNET has joined #ocaml
avsm has quit [Read error: Connection reset by peer]