dark_light changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
dechunker has quit []
pango has joined #ocaml
chessguy has joined #ocaml
danly_ has joined #ocaml
danly__ has joined #ocaml
danly__ has quit [Read error: 104 (Connection reset by peer)]
yondalf has joined #ocaml
m3ga has joined #ocaml
m3ga has left #ocaml []
mikeX has joined #ocaml
danly has quit [Read error: 110 (Connection timed out)]
fab_ has joined #ocaml
_fab has quit [Read error: 113 (No route to host)]
mikeX has quit ["leaving"]
yondalf has quit ["leaving"]
romildo has quit ["Leaving"]
Kzzch has joined #ocaml
Mr_Awesome has quit ["...and the Awesome level drops"]
Mr_Awesome has joined #ocaml
pango_ has joined #ocaml
Smerdyakov has quit ["Leaving"]
pango has quit [Remote closed the connection]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- Leading Edge IRC"]
Kzzch has quit ["The computer fell asleep"]
Kzzch has joined #ocaml
yondalf has joined #ocaml
Kzzch has quit [Read error: 110 (Connection timed out)]
yondalf has quit ["leaving"]
yondalf has joined #ocaml
llamaman has joined #ocaml
yondalf has quit [Read error: 145 (Connection timed out)]
yondalf has joined #ocaml
Mr_Awesome has quit ["and the Awesome Level drops"]
Snark has joined #ocaml
yondalf_ has joined #ocaml
yondalf has quit [Read error: 145 (Connection timed out)]
jajs has joined #ocaml
rillig has joined #ocaml
danly_ has quit ["Leaving"]
yondalf_ has quit [Read error: 110 (Connection timed out)]
yondalf has joined #ocaml
pango_ has quit [Remote closed the connection]
dark_light has joined #ocaml
yondalf has quit ["leaving"]
shawn has quit [Read error: 113 (No route to host)]
llamaman has left #ocaml []
shawn has joined #ocaml
smimou has joined #ocaml
duncanm has joined #ocaml
duncanm_ has quit [Read error: 110 (Connection timed out)]
dark_light has quit ["Ex-Chat"]
bluestorm has joined #ocaml
Kzzch has joined #ocaml
jajs has quit ["Leaving"]
Leonidas has joined #ocaml
triple_ has joined #ocaml
julien has quit ["leaving"]
bebui has joined #ocaml
bebui has quit [Client Quit]
bebui has joined #ocaml
bebui has quit [Client Quit]
bebui has joined #ocaml
bebui has quit [Client Quit]
bebui has joined #ocaml
bebui is now known as julien
jajs has joined #ocaml
lmbdwr has joined #ocaml
rillig has quit ["exit(EXIT_SUCCESS)"]
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
Leonidas has quit ["An ideal world is left as an exercise to the reader"]
Smerdyakov has quit [niven.freenode.net irc.freenode.net]
julien has quit [niven.freenode.net irc.freenode.net]
Wazm_ has quit [niven.freenode.net irc.freenode.net]
abez has quit [niven.freenode.net irc.freenode.net]
pattern has quit [niven.freenode.net irc.freenode.net]
levi_home has quit [niven.freenode.net irc.freenode.net]
gim has quit [niven.freenode.net irc.freenode.net]
Amorphous has quit [niven.freenode.net irc.freenode.net]
cmeme has quit [niven.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
julien has joined #ocaml
Amorphous has joined #ocaml
pattern has joined #ocaml
gim has joined #ocaml
abez has joined #ocaml
levi_home has joined #ocaml
Wazm_ has joined #ocaml
cmeme has joined #ocaml
cmeme has quit [Connection timed out]
cmeme has joined #ocaml
mauke has joined #ocaml
Wazm_ has quit [niven.freenode.net irc.freenode.net]
abez has quit [niven.freenode.net irc.freenode.net]
pattern has quit [niven.freenode.net irc.freenode.net]
levi_home has quit [niven.freenode.net irc.freenode.net]
gim has quit [niven.freenode.net irc.freenode.net]
Amorphous has quit [niven.freenode.net irc.freenode.net]
Smerdyakov has quit [niven.freenode.net irc.freenode.net]
julien has quit [niven.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
julien has joined #ocaml
Amorphous has joined #ocaml
pattern has joined #ocaml
gim has joined #ocaml
abez has joined #ocaml
levi_home has joined #ocaml
Wazm_ has joined #ocaml
Wazm_ has quit [niven.freenode.net irc.freenode.net]
abez has quit [niven.freenode.net irc.freenode.net]
pattern has quit [niven.freenode.net irc.freenode.net]
levi_home has quit [niven.freenode.net irc.freenode.net]
gim has quit [niven.freenode.net irc.freenode.net]
Amorphous has quit [niven.freenode.net irc.freenode.net]
Smerdyakov has quit [niven.freenode.net irc.freenode.net]
julien has quit [niven.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
julien has joined #ocaml
Amorphous has joined #ocaml
pattern has joined #ocaml
gim has joined #ocaml
abez has joined #ocaml
levi_home has joined #ocaml
Wazm_ has joined #ocaml
chessguy has joined #ocaml
romildo has joined #ocaml
buluca has joined #ocaml
chessguy has quit [" Try HydraIRC -> http://www.hydrairc.com <-"]
bzzbzz has quit ["leaving"]
Mr_Awesome has joined #ocaml
romildo has quit ["Leaving"]
setooo has quit ["bye."]
julien has quit ["leaving"]
bebui has joined #ocaml
triple_ has quit [Read error: 113 (No route to host)]
pango has joined #ocaml
jajs has quit ["Leaving"]
bluestorm is now known as bluestorm_aw
pango has quit [Remote closed the connection]
pango has joined #ocaml
mauke has quit ["reid"]
Snark has quit ["Leaving"]
Leonidas has joined #ocaml
<dan2> pango: have you ever tried to make C bindings to ocaml?
<pango> no
<dan2> have you used the lazy constructs?
jajs has joined #ocaml
<pango> lazy values, not streams yet
<dan2> pango: how would you implement fibonacci lazily?
<dan2> assuming fib n = fib' n 0 1
<dan2> in let rec fib' a b c =
<dan2> match a with
<dan2> | a when a < 1 -> b
<dan2> | a -> fib' (pred a) (b+c) b;;
bluestorm_aw is now known as bluestorm
<pango> type 'a llist = LEmpty | LList of 'a * 'a llist Lazy.t
<pango> let rec fib' m n = LList (n, lazy (fib' n (m+n)))
<pango> let fib = fib' 0 1
<pango> (if not mistaken)
* dan2 checks
<dan2> how would you get the next fibonacci number?
<pango> actually it must be let rec fib' m n = LList (m, lazy (fib' n (m+n))), or you lose the first element
<dan2> is there a reason why you can't use existing list constructs?
<pango> they're not lazy
<pango> :: constructs a list from a 'a and a 'a list, not a 'a and a 'a list Lazy.t
<dan2> I see
<pango> that's probably much nicer with streams, that are basically the same thing with some syntactic sugar on top :)
<dan2> how would I adjust that just to produce the last element n as an integer and not through print?
<pango> let rec nth ll n =
<pango> match ll with
<pango> | LEmpty -> invalid_arg "nth"
<pango> | LList (e, q) -> if n = 0 then e else nth (Lazy.force q) (n-1)
<pango> not too different from List.nth
<dan2> ok
<dan2> pango: how does the standard recursive fibonacci (as described above) compare to this lazy one?
<pango> elements of the lazy list are only evaluated once... If you use fib again, previous results will be reused
<dan2> oh, that's interesting
<dan2> so it memoizes it huh?
<pango> (doesn't that term apply to functions only ?)
<dan2> well memoization is all about storing previous results
<dan2> given that f(x) will always = n, cache (x,n)
<pango> # fib ;;
<pango> - : int llist = LList (0, <lazy>)
<pango> # nth 3 fib ;;
<pango> - : int = 2
<pango> # fib ;;
<pango> - : int llist =
<pango> LList (0, lazy (LList (1, lazy (LList (1, lazy (LList (2, <lazy>)))))))
<dan2> neato
<dan2> so initial run is O(n), and every other time O(1)
<pango> sure, but fib is not a function, it's a (lazy) value
<dan2> but it caches values, so it's very similar
<pango> well, to get the nth element, you still have to traverse n elements, like List.nth
<dan2> memoization is usually a wrapper function around a function to save time down the road
<pango> but additions are only done once
<pango> that's how I understand the term memoization too, and why I'm not sure it applies here
<dan2> it just caches entries as they're accessed in the list
<Smerdyakov> "Lazy" is implemented with wrapper functions, no doubt; it's just that their domains are 'unit'.
<dan2> pango: the value is there when you're using a Big number library with something like this
<pango> well, implementation is straightforward, I'm just not sure one can use "memoization" and "lazy values" interchangeably. For one, both can be used to solve some kinds of problems... and they usually lead to different implementations
bebui has quit ["leaving"]
bebui has joined #ocaml
bebui has quit [Client Quit]
bebui has joined #ocaml
TFK has joined #ocaml
ziggurat has joined #ocaml
<pango> (at least, used to be straightforward; it seems that they're now using a more efficient representation, with some help from the runtime...)
<dan2> I wish I understood more of what the hell I'm doing with camlidl
ziggurat has quit ["This computer has gone to sleep"]
<dan2> Smerdyakov: how easy did you say the foreign function interface with SML was?
<Smerdyakov> There is no standard SML FFI.
<Smerdyakov> I said that the MLton FFI was trivial to use.
<dan2> Smerdyakov: does it allow for easy use of function pointers?
<Smerdyakov> I don't know.
<dan2> I should just finish this with camlidl
ziggurat has joined #ocaml
mauke has joined #ocaml
jajs has left #ocaml []
bluestorm has quit ["Konversation terminated!"]
malc_ has joined #ocaml
mikeX has joined #ocaml
<mikeX> is there a way to somewhat emulate the behavior of raise, as in make a funtion that returns 'a regardless of input?
<ulfdoz> nope, you must qualify (correct term) a type in some way.
<pango> end with a function that doesn't return: raise itself, assert, ...
<malc_> pango: Obj.magic
<mikeX> well raise and assert interrupt execution, that's what I'm trying to avoid
<pango> well, I was thinking of answers that do not break havok ;)
<pango> mikeX: I do not see how that could work
<mikeX> I see, thanks
<pango> if condition then something else mymagicpolymorphicfunction ()
<mauke> you're doing something wrong
<pango> if the return value of the function is polymorphic, that expression will always be correctly typed, no matter what "something" returns
<mauke> yeah. it also doesn't make any sense.
<pango> receipe for disaster
<mikeX> mauke: well I have a function that could raise Terminate, but doesn't always (based on some kriteria and with the help of kfprintf). I was trying to find a way to avoid having to return something on match e with .. | _ -> that_function ()
<mauke> what's the context of that match?
<pango> mikeX: much like if/then/else construct above, typing requires that the value returned by all branches have the same type
<mauke> and what kind of value is that_function () supposed to return?
<mikeX> well kfprintf returns ()
<malc_> i think the format hack issue has been raised numerous times on the ML
smimou has quit ["bli"]
david_koontz_ has joined #ocaml
malc_ has quit ["leaving"]
david_koontz has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]