gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
<thelema> mrvn: any idea on where the two algorithms differ? more insertion speed vs. more deletion speed?
gnuvince has quit [Quit: C-x C-c]
fraggle_ has quit [Remote host closed the connection]
gnuvince has joined #ocaml
<thelema> more update speed?
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 272 seconds]
ulfdoz_ is now known as ulfdoz
fraggle_ has joined #ocaml
tautologico has joined #ocaml
smerz has quit [Remote host closed the connection]
ftrvxmtrx_ has quit [Ping timeout: 245 seconds]
oriba has quit [Quit: oriba]
letrec has joined #ocaml
roha has joined #ocaml
roha has quit [Ping timeout: 260 seconds]
struktured has joined #ocaml
avsm has quit [Quit: Leaving.]
NotADJ has joined #ocaml
NotADJ has quit [Excess Flood]
NotADJ has joined #ocaml
NotADJ has quit [Excess Flood]
NotADJ has joined #ocaml
NotADJ has quit [Disconnected by services]
TDJACR has joined #ocaml
tautologico has quit [Quit: tautologico]
ggherdov has joined #ocaml
ggherdov has quit [Remote host closed the connection]
mattrepl has quit [Quit: mattrepl]
BiDOrD has joined #ocaml
BiDOrD_ has quit [Ping timeout: 245 seconds]
ftrvxmtrx has joined #ocaml
mmajchrzak has joined #ocaml
johnnowak has joined #ocaml
clog has joined #ocaml
hiptobecubic has joined #ocaml
roha has joined #ocaml
Cyanure has joined #ocaml
avsm has joined #ocaml
BiDOrD has quit [Ping timeout: 260 seconds]
BiDOrD has joined #ocaml
Submarine has joined #ocaml
letrec has joined #ocaml
ggherdov has joined #ocaml
roha has quit [Ping timeout: 276 seconds]
roha has joined #ocaml
roha has quit [Ping timeout: 246 seconds]
ftrvxmtrx has quit [Ping timeout: 248 seconds]
<mrvn> Anyone know of a GUI, preferably with ocaml bindings, that is base on sdl? Something game friendly. Nothing complex.
<mrvn> thelema: Fibonacci Heaps have O(1) insertion. They put off the works for balancing till you delete something.
<mrvn> thelema: And O(1) decrease key, same deal.
<adrien> even stuff with pure C, there's not much that is game friendly
<adrien> maybe that another solution would be to have an "sdl" widget
<adrien> which is not a big issue iirc (possibly through opengl)
<mrvn> A gui that works with lablgl could be good too.
MaskRay has joined #ocaml
<adrien> what I had in mind was: your own GUI in lablgtk, with the game stuff inside a central widget
<mrvn> thelema: "Find-minimum is O(1) amortized time.[1] Operations insert, decrease key, and merge (union) work in constant amortized time.[2]. Operations delete and delete minimum work in O(log n) amortized time[2]. This means that starting from an empty data structure, any sequence of a operations from the first group and b operations from the second group would take O(a + b log n) time. In a binomial heap such a sequence of o
<mrvn> adrien: All games tend to have one large game area in the middle. Most have some sort of mini map to the side. And the rest just a buch of buttons.
<mrvn> s/buch/bunch/
<adrien> displaying infos in games is not easy
<adrien> even health bars for players can be pretty annoying
<mrvn> And inbetween games you need some menu structures, file dialogs for load/save with scrollable lists and maybe a preview and so on.
oriba has joined #ocaml
eni has joined #ocaml
eni is now known as albacker
albacker has quit [Quit: Leaving]
Smerdyakov has joined #ocaml
Smerdyakov has left #ocaml []
ftrvxmtrx has joined #ocaml
<mrvn> 0.694000 seconds for a goto. That will not work. :(
struktured has quit [Remote host closed the connection]
struktured has joined #ocaml
smerz has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
iago has joined #ocaml
TDJACR has quit [Read error: Operation timed out]
TDJACR has joined #ocaml
mattrepl has joined #ocaml
letrec has quit [Ping timeout: 255 seconds]
struktured has quit [Read error: No route to host]
carm_ has joined #ocaml
malouin_ is now known as tchell
milosn has quit [Read error: No route to host]
milosn has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
avsm has quit [Client Quit]
avsm has joined #ocaml
gnuvince has quit [Quit: C-x C-c]
MaskRay has left #ocaml []
carm_ has quit [Remote host closed the connection]
struktured has joined #ocaml
gnuvince has joined #ocaml
philed has joined #ocaml
<adrien> anyone knows how sexplib handles the following s-expression?
<adrien> (foo "bar "something" baz")
<adrien> ?
<pippijn> adrien: (foo "bar " something " baz")
<pippijn> a list with 4 atoms
tmaeda is now known as tmaedaZ
<mrvn> thelema: are liquid types some form of formal validation of code or should they be part of the compilers type checking?
<adrien> pippijn: hmm, forgot to say that it's supposed to be a record field
<adrien> with "foo" being the name
<adrien> but I doubt it reads the rest as only one string
<mrvn> adrien: { foo="bar "; something=" baz"; }?
<mrvn> adrien: or { foo = "bar "something" baz"; }?
<adrien> I wish it did the second one
<adrien> I'm going to have to try
<mrvn> adrien: I'm asking about your input
<adrien> the source is not controlled but is friendly
<adrien> mrvn: I want from "string/sexp" to ocaml record; but I'll try (but even it works, it might be unspecified and might be something I can't rely on)
tmaedaZ is now known as tmaeda
<pippijn> adrien: it doesn't read things differently depending on the context
<pippijn> adrien: Sexp.of_string doesn't know about records
<adrien> for sexplib, a record is a list of lists of strings of length 2
<adrien> so, yeah, a string, but the question was about how it interprets it later on
<adrien> and, currently, what I "wanted" does not work
jbapple1 has joined #ocaml
jbapple has quit [Ping timeout: 245 seconds]
GPHemsley has joined #ocaml
<GPHemsley> Is there a way to have a list of multiple different types?
<adrien> no
<GPHemsley> (It's OK/better if I can restrict it to only certain types.)
<adrien> what you can do is have a sum type instead
<adrien> type t = Float of float | Int of int
<adrien> let l = [ Float 3.14; Int 42 ]
<GPHemsley> ah, OK
<GPHemsley> is there a way to define a type using only the types without the constructors?
<mrvn> or [ `Float 3.14; `Int 42 ]
<GPHemsley> mrvn: Yeah, I was just looking at that syntax... what exactly does it mean?
<mrvn> GPHemsley: as in type my_type = Float | Int?
<GPHemsley> mrvn: more like type t = float | int
<mrvn> GPHemsley: `foo is a hash variant. The constructors are not numbers 0,1,2,... but "Foo" is hashed and that is used as the number for the constructor.
<GPHemsley> like, say I have type t1 = Foo of string, type t2 = Bar of string; then I want to do type allt = Foo | Bar
<mrvn> GPHemsley: But that is more the internal detail. What it means for you is that you can create subsets and supersets.
<GPHemsley> but then OCaml complains if I have Foo( "baz" )
<GPHemsley> (apologies for the interweaving conversations here)
<mrvn> Your second "Foo" type shadows the first
<GPHemsley> mrvn: That's what I'd expect, but it didn't seem to work that way
<GPHemsley> I'll try it again
<GPHemsley> it complains about number of arguments
<mrvn> # type t1 = Foo of string let make_foo s = Foo s type t2 = Bar of string let make_bar s = Bar s type allt = Foo | Bar let (x,y,z) = (make_foo "foo", make_bar "bar", Foo);;
<mrvn> GPHemsley: Yes, because your second Foo has no arguments.
<GPHemsley> what I really want is type allt = t1 | t2
<mrvn> GPHemsley: first thing would be: type allt = Foo of string | Bar of string
<GPHemsley> right, but that duplicates code... :/
<GPHemsley> is that the only way to do it
<GPHemsley> ?
<mrvn> But again that would declare a new Foo shadowing the first.
<mrvn> type allt = T1 of t1 | T2 of t2, that adds another indirection
<mrvn> GPHemsley: A Foo "s" of type allt is not of type t1
<GPHemsley> meh
<GPHemsley> can I define a type such that the same constructor can have two different types?
<GPHemsley> like Foo of int | Foo of string
<mrvn> If you need to resuse the constructor names you can do so with hash variant types: # type t1 = [`Foo of string] type t2 = [`Bar of string] type allt = [`Foo of string | `Bar of string];;
<mrvn> type t1 = [ `Foo of string ]
<mrvn> type t2 = [ `Bar of string ]
<mrvn> type allt = [ `Bar of string | `Foo of string ]
<mrvn> GPHemsley: you can't. Even if you could the "Foo of string" would shadow the "Foo of int" making it impossible to create one.
<mrvn> and you can't have type t = int | float. There is a project to add such runtime types to ocaml though.
vork has joined #ocaml
<mrvn> There are also some ocamlp4 modules that create you a type_of type for any type you declare.
<vork> How can I declare an instantiation of the Set functor in an mli file?
<vork> "module TSets : Set.S" doesn't expose what the element type is.
<mrvn> module Ord = struct type t = int let compare = compare end module S = Set.Make(Ord)
<mrvn> then ocamlc -i that
<mrvn> vork: or do you mean "S with type elt = Ord.t"?
<vork> Ahh, that's what I want, thanks.
<mrvn> Can one specify the functor instanciation in the .mli file without listing the whole sig?
roha has joined #ocaml
<mrvn> I can't seem to get the "with" syntax to work.
<vork> module VarSets : Set.S with type elt = var
<vork> works for me
<mrvn> ahh, stupid me. had a typo in there.
<thelema> mrvn: they're in the intersection of formal validation and type checking
NougatRillettes has quit [Quit: NougatRillettes]
<mrvn> Why isn't the Weak Hashtbl called Hashset?
<thelema> because weak pointers
<mrvn> That's not what I mean.
<mrvn> Hashtbl is ('a, 'b) Hashtbl.t, key -> data. A Weak Hashtbl is just data, no keys.
<thelema> true
<mrvn> Its is more like a Set except that values are hashed and stored in an array instead of tree. => Hashset
<thelema> yes, hashtbl with values all ()
<mrvn> I'm wondering how to do an actual weak ('a, 'b) Hashtbl. I don't think I can make it so it can be resized. Unless I use an 'a array + 'b Weak.t
<mrvn> thelema: values all equal to the key, ('a, 'a) Hashtbl.t
<thelema> why do you want a weak ('a, 'b) hashtbl?
<mrvn> thelema: As cache. I have a large image containing an array of smaller images. Now I want "Image.get big x y" to return the same copy of the region of big each time.
<thelema> don't use weak for caching.
<thelema> use a real cache structure.
<thelema> There's been plenty written about why weak pointers make terrible caches
<mrvn> The code loads the big image, then extracts a bunch of tiles from that with tiles being extracted multiple times and then the big image is forgotten and the cache will get cleared by the GC.
<thelema> if your cache goes away after you're done extracting, use BatCache.manual_cache
<mrvn> thelema: How is that better?
<thelema> because if there's GC pressure in the middle of running the extraction, you won't thrash your system loading tiles multiple times and then having GC discard them
<mrvn> thelema: Creating another copy of a tile is cheap. But the memory is expensive. So as long as there exists a copy of a tile the next get should return the same copy. If the GC cleaned it out I create a new one.
<thelema> ah, you just want hash-consing for live values
<thelema> this isn't a cache.
<mrvn> My understanding is that Weak.t will only forget about the tile if it is no longer in use anywhere else.
<thelema> for that, write your own (=) and hash functions that ignore the 'b part of a pair.
<mrvn> thelema: using type data = key * image?
<mrvn> Wouldn't the GC then remove entries when (key, image) is no longer used even if image itself is in use?
Zedrikov has joined #ocaml
Kakadu has joined #ocaml
fraggle_ has quit [Ping timeout: 252 seconds]
fraggle_ has joined #ocaml
hiptobecubic has quit [Ping timeout: 245 seconds]
nikodim has joined #ocaml
nikodim has quit [Client Quit]
ulfdoz has quit [Ping timeout: 252 seconds]
ulfdoz has joined #ocaml
<thelema> mrvn: hmm, yes...
<thelema> you need weak hashconsing
<mrvn> what I do now is allocate a fixed size Weak.t and using Weak.set arr (hash key) img. The key is not stored so I can't resize nor detect hash collisions.
djcoin has joined #ocaml
vork has left #ocaml []
philed has quit [Ping timeout: 246 seconds]
<thelema> mrvn: use a real hashtbl ('a, int) and a weak.t; whenever you want to look the result of f x, do a hashtbl lookup to get the index into the weak array based on x, and if the weak array has something in that cell, use that.
<thelema> if not, compute the value you want and put it in the weak array
<mrvn> or simply just Hashtbl.t. The Hashtbl fill be freeed after loading.
<thelema> yes, if you only need it for a short while. which is exactly what BatCache does
<thelema> (it also has a tree implementation; sometimes better0
<mrvn> I have animations for moving units as list of tiles for 6 directions. But I only have a tux going left and right. So right, right up and right down are the same set of tiles. I just don't want to use up 3 times the memory.
Submarine has quit [Quit: Leaving]
`micro has joined #ocaml
nikodim has joined #ocaml
Zedrikov has quit [Quit: Bye all, see you next time!]
Kakadu has quit [Quit: Konversation terminated!]
larhat has joined #ocaml
larhat has quit [Quit: Leaving.]
djcoin has quit [Read error: Operation timed out]
roha has quit [Ping timeout: 250 seconds]
djcoin has joined #ocaml
nikodim has quit [Quit: Page closed]
roha has joined #ocaml
Cyanure has quit [Remote host closed the connection]
djcoin has quit [Quit: WeeChat 0.3.2]
bnwr has quit [Quit: leaving]
hiptobecubic has joined #ocaml
mnabil has joined #ocaml
Anarchos has joined #ocaml
tufisi has quit [Ping timeout: 260 seconds]
roha has quit [Ping timeout: 272 seconds]
roha has joined #ocaml
johnnowak has joined #ocaml
mnabil has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 252 seconds]
gnuvince has quit [Quit: C-x C-c]
ulfdoz has joined #ocaml
johnnowak has quit [Quit: Leaving.]
roha has quit [Ping timeout: 252 seconds]
letrec has joined #ocaml
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
tmaeda is now known as tmaedaZ