ulfdoz has quit [orwell.freenode.net irc.freenode.net]
zmdkrbou_ has quit [orwell.freenode.net irc.freenode.net]
shawn has quit [orwell.freenode.net irc.freenode.net]
descender has quit [orwell.freenode.net irc.freenode.net]
mw has quit [orwell.freenode.net irc.freenode.net]
datrus has quit [orwell.freenode.net irc.freenode.net]
fremo has quit [orwell.freenode.net irc.freenode.net]
l_a_m has quit [orwell.freenode.net irc.freenode.net]
buluca has quit [orwell.freenode.net irc.freenode.net]
dbueno has quit [orwell.freenode.net irc.freenode.net]
Hadaka has quit [orwell.freenode.net irc.freenode.net]
seafood_ has quit [orwell.freenode.net irc.freenode.net]
bohanlon has quit [orwell.freenode.net irc.freenode.net]
lmbdwr__ has quit [orwell.freenode.net irc.freenode.net]
pingu has quit [orwell.freenode.net irc.freenode.net]
eradman has quit [orwell.freenode.net irc.freenode.net]
mattam has quit [orwell.freenode.net irc.freenode.net]
Ugarte has quit [orwell.freenode.net irc.freenode.net]
batdog has quit [orwell.freenode.net irc.freenode.net]
Norgg has quit [orwell.freenode.net irc.freenode.net]
knobo has quit [orwell.freenode.net irc.freenode.net]
falconair has quit [orwell.freenode.net irc.freenode.net]
Amorphous has quit [orwell.freenode.net irc.freenode.net]
ppsmimou has quit [orwell.freenode.net irc.freenode.net]
nattfodd has quit [orwell.freenode.net irc.freenode.net]
pango_ has quit [orwell.freenode.net irc.freenode.net]
mikeX has quit [orwell.freenode.net irc.freenode.net]
slipstream has quit [orwell.freenode.net irc.freenode.net]
julien has quit [orwell.freenode.net irc.freenode.net]
duncanm has quit [orwell.freenode.net irc.freenode.net]
levi_home has quit [orwell.freenode.net irc.freenode.net]
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
TSC has quit [orwell.freenode.net irc.freenode.net]
jdev has quit [orwell.freenode.net irc.freenode.net]
RSi has quit [orwell.freenode.net irc.freenode.net]
chessguy has quit [orwell.freenode.net irc.freenode.net]
Mr_Awesome has quit [orwell.freenode.net irc.freenode.net]
Payo543 has quit [orwell.freenode.net irc.freenode.net]
shans_home_ has quit [orwell.freenode.net irc.freenode.net]
david_koontz has quit [orwell.freenode.net irc.freenode.net]
TaXules has quit [orwell.freenode.net irc.freenode.net]
Demitar has quit [orwell.freenode.net irc.freenode.net]
Oatmeat|umn has quit [orwell.freenode.net irc.freenode.net]
flux__ has quit [orwell.freenode.net irc.freenode.net]
ozzloy has quit [orwell.freenode.net irc.freenode.net]
buggs has quit [orwell.freenode.net irc.freenode.net]
cmeme has quit [orwell.freenode.net irc.freenode.net]
mw has joined #ocaml
descender has joined #ocaml
ulfdoz has joined #ocaml
shawn has joined #ocaml
zmdkrbou_ has joined #ocaml
Hadaka has joined #ocaml
dbueno has joined #ocaml
buluca has joined #ocaml
l_a_m has joined #ocaml
fremo has joined #ocaml
datrus has joined #ocaml
chessguy has joined #ocaml
pango_ has joined #ocaml
lmbdwr__ has joined #ocaml
Mr_Awesome has joined #ocaml
Payo543 has joined #ocaml
knobo has joined #ocaml
shans_home_ has joined #ocaml
seafood_ has joined #ocaml
slipstream has joined #ocaml
david_koontz has joined #ocaml
julien has joined #ocaml
TaXules has joined #ocaml
duncanm has joined #ocaml
falconair has joined #ocaml
levi_home has joined #ocaml
Smerdyakov has joined #ocaml
Amorphous has joined #ocaml
TSC has joined #ocaml
ppsmimou has joined #ocaml
pingu has joined #ocaml
Demitar has joined #ocaml
eradman has joined #ocaml
mattam has joined #ocaml
Oatmeat|umn has joined #ocaml
flux__ has joined #ocaml
cmeme has joined #ocaml
Ugarte has joined #ocaml
buggs has joined #ocaml
ozzloy has joined #ocaml
nattfodd has joined #ocaml
Norgg has joined #ocaml
RSi has joined #ocaml
jdev has joined #ocaml
batdog has joined #ocaml
bohanlon has joined #ocaml
pango_ has quit [Excess Flood]
pango_ has joined #ocaml
jdev has quit ["Secruity!"]
danly has joined #ocaml
ziggurat has joined #ocaml
chessguy has quit [Connection timed out]
jordan has joined #ocaml
<jordan>
what is the problem with the following expression: List.fold_left (fun (a, b) -> a) [] [('c', 'b')];; ? I intend to take the first of the tuple and put it in a list
Smerdyakov has quit ["Leaving"]
<Payo543>
someone wanna give me a camelia binary for me :D
<levi_home>
jordan: There's no cons operation in your function.
<Mr_Awesome>
List.map fst [] ['c', 'b'];;
<levi_home>
Among other things.
<Mr_Awesome>
i mean List.map fst ['c', 'b]
<Mr_Awesome>
well you know what i mean ;)
<levi_home>
Mr_Awesome: That's not quite what he's trying to do.
<Mr_Awesome>
hmm, what is it then?
danly has quit ["Leaving"]
<jordan>
levi_home I thought it should just accumulate things in the second argument
<jordan>
so apply the first argument to the first of the list, put it in there accum, do it for the second, etc.
<levi_home>
No, it doesn't automatically accumulate.
<levi_home>
For example, List.fold_left (+) 0 [1; 2; 3; 4]
<levi_home>
There, consing things into a list would be a type error.
<jordan>
I see. I'm trying to rework it with a cons in the right place
<jordan>
since the function I'm applying only has access some element of the list, I don't see how I could cons it to the accumulator -- it doesn't have access to the accum, right ?
<levi_home>
It's one of the arguments passed to the function.
<levi_home>
It should be a function of 2 arguments.
<Mr_Awesome>
i still dont get what hes trying to do...
danly has joined #ocaml
<levi_home>
jordan: You probably want List.map instead of List.fold_left, anyway.
<pango_>
List.fold_left (fun acc (a, b) -> a :: acc) [] [('c', 'b')];; ?
MisterC has quit [Read error: 104 (Connection reset by peer)]
AStorm has quit []
fab_ has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
dark_ has joined #ocaml
stesch has joined #ocaml
<dark_>
there are any good way to make an unamed pipe using in/out channels? i am trying this http://nopaste.tshw.de/11612904855c2ec/ and apparently is working very well but someone here said that when working with sockets one should never use in/out channels.. so i am thinking, maybe there are any con to use this method..
dark_ is now known as dark_light
katatsumuri has joined #ocaml
duncanm_ has quit [Read error: 110 (Connection timed out)]
duncanm has joined #ocaml
bluestorm has quit ["Konversation terminated!"]
<katatsumuri>
Did anyone try to do game programming with OCaml?
<dark_light>
i plan to :P
<katatsumuri>
hehe
<katatsumuri>
do you know the language?
<dark_light>
actually i am trying to make my telnet-based mmorpg for the 100th time.. right now
<dark_light>
katatsumuri, some of, did you saw my question before?
<katatsumuri>
i just signed in a moment ago
<dark_light>
oh you entered after, let's see
<dark_light>
<dark_> there are any good way to make an unamed pipe using in/out channels? i am trying this http://nopaste.tshw.de/11612904855c2ec/ and apparently is working very well but someone here said that when working with sockets one should never use in/out channels.. so i am thinking, maybe there are any con to use this method..
aleXXX_ has joined #ocaml
<aleXXX_>
hi
<katatsumuri>
hmm. i am very new to ocaml.
<katatsumuri>
hello
<katatsumuri>
trying to learn how to program in a functional style
<dark_light>
hi aleXXX_
<aleXXX_>
I need some help with the tools (ocamlc, ocamldep and ocamlopt)
<katatsumuri>
but i come from c and c++ and such and i am used to have variables.
<aleXXX_>
I'm working on the KDE buildsystem and there we have ocaml in kalzium
<dark_light>
katatsumuri, it's amazing :) but the details sometimes is annoying (the form the ocaml treats printf and object types looks bad..)
<dark_light>
katatsumuri, well, it's a bit weird in the beginning.. but remember you can use imperative programming too
<aleXXX_>
can I specify the file name and directory where ocamlc should generate the cmi file from the mli file ?
<katatsumuri>
yes... but i want to update states of a game entity
<katatsumuri>
i was looking at the code for freetennis
<katatsumuri>
and found this
<katatsumuri>
let p = {p with hp_state = newst} in
<katatsumuri>
where p is the player
<aleXXX_>
dark_light: the man page says:
<aleXXX_>
-o exec-file
<aleXXX_>
Specify the name of the output file produced by the linker.
<katatsumuri>
it seems like this is the way to change the cariable hp_state in the player type
<aleXXX_>
so is every file generated by ocamlc an "exec-file" ?
<dark_light>
katatsumuri, i never used before this syntax, seems much like of pattern matching against records
<dark_light>
aleXXX_, well, i think no. it behaves in a other way when compiling from an .mli file
<katatsumuri>
i have not seen it explained in any tutorial or document
<katatsumuri>
let newPlayer = { p with
<katatsumuri>
hp_objLeading = newObjLead2;
<katatsumuri>
hp_objSlave = newObjSlave2;
<katatsumuri>
...
<katatsumuri>
} in
<aleXXX_>
how are the dependencies of a ml file determined ?
<katatsumuri>
here he seems to set a bunch of new variables for newPlayer
<dark_light>
aleXXX_, by the calls to external modules
<aleXXX_>
by running ocamldep ?
<dark_light>
aleXXX_, i never used ocamldep before, i determine this manually
<dark_light>
aleXXX_, if you have let x = Unix.pipe() in your code, you will need unix.cma
<dark_light>
katatsumuri, well it seems to use an functional approach for this
<aleXXX_>
like "Open Chemset;;" I guess
<dark_light>
katatsumuri, i am not sure if it's the best way to handle with mutable states of a player
<dark_light>
aleXXX_, open Chemset is an use of an external module, too
<katatsumuri>
how would you handle it? i really think OOP here. i want the entity to own it's state.
<aleXXX_>
ah, I see
<dark_light>
katatsumuri, currently i am using objects to do many things, so i would try to make a class for the players..
<katatsumuri>
and position for example...
<katatsumuri>
but classes seem similar to a type with mutable fields
<katatsumuri>
and this is not very functional either
<dark_light>
katatsumuri, well i am beginning to think OOP when it comes with dealing with mutable states
<katatsumuri>
if i have understood things right
<katatsumuri>
but isn't everything in an application mutable in some way then?
<dark_light>
well.. you don't need to be very functional..
<dark_light>
katatsumuri, objects aren't exactly a record, but i don't know the details of implementation
<dark_light>
katatsumuri, if i would use records, my functions would receive the player and change it, that's all
Pay542 has quit [Remote closed the connection]
<katatsumuri>
no but somewhat similar
<dark_light>
katatsumuri, like let kill_player myplayer = myplayer.isalive <- false
<aleXXX_>
dark_light: am I right that a foo.mli file is used to generate a foo.cmi file, and this one is used together with foo.ml to create a foo.cmx ?
<katatsumuri>
i want to change the way i think about programming... i could do the programming as usual with ocaml, imperative and with objects and have ocaml as a more safe C++
* dark_light
wondering if this is the correct syntax
<dark_light>
katatsumuri, well.. :)
<katatsumuri>
i understand :-)
<katatsumuri>
and i also worry about performance
<dark_light>
aleXXX_, it may be used, or if none is provided the ocaml will generate it automatically (i think)
<dark_light>
katatsumuri, performance is always always always my last worry
<aleXXX_>
dark_light: what may be used ? the mli file ?
<katatsumuri>
if i do a :: [lots of items here] to put the item a into the list
<katatsumuri>
then i think ocaml will allocate a new list and then garbage collect the old one.
<katatsumuri>
what if the tail contained thousands of objects
<dark_light>
aleXXX_, it can use nothing if you prefer (but the module will not be acessible by others modules)
<dark_light>
katatsumuri, i have no idea but this has a great performance
<katatsumuri>
i guess they do something "smart" :-P
<aleXXX_>
I mean, we have some build rules where it seems to be as I described. I want to find out if this is a general rule how to build this tuff
<katatsumuri>
found an explanation of with in the ocaml book. this usage is an extension and may change.
<katatsumuri>
well... i guess i will read that book from cover to cover :-D
<pango>
katatsumuri: the tail *is* the end of the new list
<katatsumuri>
i can't be...
<pango>
katatsumuri: since lists are immutable, there's no point in making a copy
<katatsumuri>
because someone else could have a copy of the tail...
<katatsumuri>
hmm..
<katatsumuri>
it could!
<dark_light>
aleXXX_, well hmmm the .cmi is only meant to make using external modules safer, it's only the signature of module..
<pango>
dark_light: from what I understand, the problem with channels is that they're buffered, and there's no "select" type operation on them
<pango>
dark_light: so the only way to use them in a non blocking way is threads
<pango>
katatsumuri: so what? it's immutable
<dark_light>
pango, hmmmm fine then
<katatsumuri>
but someone might want to keep only the tail. but i guess that the list is only forward linked.
<pango>
katatsumuri: yes
<dark_light>
pango, what about an int ref list? still immutable?
<katatsumuri>
so someone holdig onto the tail cannot "back up" and see the added items.
<pango>
dark_light: the list is immutable. The elements may not be
<aleXXX_>
dark_light: later on the cmx files are put together to a .o file, which is then used together with C/C++
<katatsumuri>
that really explains why you cannot append, only prepend to lists!
<aleXXX_>
I don't see where the cmi files are used
<pango>
dark_light: as soon as you mix mutable and immutable, you must think about sharing
<pango>
dark_light: for purely immutable datastructures you don't have to, because semantically it doesn't matter
<dark_light>
aleXXX_, used only in the type inference checker during the compilation of the .cmx, or something like this
<dark_light>
aleXXX_, if something goes wrong, it simply doesn't compile. if it's ok, it don't use the .cmi for nothing more. it's what i think
<dark_light>
pango, hmmmm
<katatsumuri>
hmm :-)
<aleXXX_>
dark_light: ?
<pango>
aleXXX_: interface restricts what's visible to other modules
<katatsumuri>
insertion and removal from the end of the list must be slower
<pango>
katatsumuri: yes,... "don't do that then"
<katatsumuri>
so what should i do instead?
<pango>
katatsumuri: build the list in reverse, and reverse it as a last step if needed
<katatsumuri>
i think that i would have a list with game entities. some of them die and need to be removed from the list.
<pango>
katatsumuri: then you don't need a list
<pango>
katatsumuri: but a Set, a Hashtbl, whatever
<katatsumuri>
i guess
<dark_light>
Set? it helps removing?
<dark_light>
i am thinking in use hashtbl for storing player's data. i have an unique id (that is an int) that will point to an.. well, i don't know (yet) how to represent a player
<pango>
Sets are functional, but building a new Set with one less element is an O(log n) operation, iirc
<dark_light>
maybe a record
velco has quit ["I'm outta here ..."]
<katatsumuri>
sounds like that int will work as a pointer
<dark_light>
i think is somewhat stupid using hashtables indexed by.. ints.. because it's was meant to strings.. well it's what i guess..
<dark_light>
katatsumuri, yes :>
<katatsumuri>
so you could get ints "pointing" to nothing or maybe another entity that happened to take the same id.
<pango>
dark_light: Hashtbl are meant for abstract datastructures (as modules) that provide an equality relation and a hash function
<dark_light>
katatsumuri, the same id? it will be difficult. but pointing to nothing is easy to check
_velco has joined #ocaml
<katatsumuri>
if you can check it in one single place
<katatsumuri>
and not in a hundred places in the game
<dark_light>
katatsumuri, i am using let unique = let i = ref 0 in (fun () -> incr i; !i) .. so the first unique() will return 1, the other will return 2.. and when the int overflow and then reach the zero again i might be in trouble. :-)
<dark_light>
i will use a function that grabs info by the id, so the check will be done in only one place
<katatsumuri>
ok
<katatsumuri>
:-)
<katatsumuri>
i have to learn a lot more about ocaml
<dark_light>
i have to learn a lot more about c++
<katatsumuri>
that i know :-=
<katatsumuri>
:-)
<katatsumuri>
but i don't like c++ anymore
<dark_light>
i should not be playing in ocaml right now, but c++ is painful :>
<katatsumuri>
c++ is just full of traps
<katatsumuri>
basically everything that can be done is wrong
<dark_light>
katatsumuri, i worshipped C/C++ (i didn't knew the difference) a few years ago. now C seems simple and not very interesting, and C++ seems a big fat programming language
<katatsumuri>
C is still interesting for binding stuff to ocaml :-)
<katatsumuri>
i tried to do some OpenGL calls though a C binding.
<katatsumuri>
I guess C++ is better and safer but it is really too complex. Noone at my work really understands it fully it seems.
<katatsumuri>
And they have been working for years.
<pango>
record can be used in plain functional way (with no mutable fields), or as (partially) mutable structures
<dark_light>
katatsumuri, there are an opengl lib for ocaml..
<pango>
the { old_record with field = value } syntax is very useful when they're used in a functional way, but can be used for shallow copying any kind of record
<dark_light>
pango, it will copy the *entire* record?
<katatsumuri>
is it safe to use with in this way? i guess that if the keyword would disappear it can still be done manually.
<pango>
dark_light: yes, create a new shallow copy of the record with the changes you demanded
<katatsumuri>
dark_light: I didn't want to use any of the existing OpenGL bindings. I didn't feel free and safe that way. :-)
<dark_light>
:o
_velco has quit ["I'm outta here ..."]
<pango>
katatsumuri: correct, it's for convenience
<katatsumuri>
i see
<katatsumuri>
dark_light: But I am not doing an OpenGL binding. Instead i could make a function such as "draw_quad" which makes the OpenGL calls that draws a quad.
<katatsumuri>
dark_light: This way I don't have to bind all OpenGL functions. I just wrap them up with an easier interface. Easier and it should perfrom better.
<dark_light>
katatsumuri, hmm.. i see.. well :P the worse thing in c++ for me is the name of the functions that i sometimes find in some libraries, i can't understand why someone would name a function with a name like myNewFunctionIsHereWohoo.. the opengl binding i saw was with the same names of original functions, and it was not very nice for me..
<katatsumuri>
what's wrong with that naming? :-)
<dark_light>
it's too ugly :D
<katatsumuri>
it's common. dont judge a language by that :-)
<katatsumuri>
most OOP people would be scared by the lowercase_underscore_function_names
Skal has joined #ocaml
fab_ has quit []
<dark_light>
i recently tried to name the variables like player-request.. i can't because the ocaml things it's a subtraction, oh well :-(
<katatsumuri>
hehe
<pango>
you can use quotes, but I wouldn't recommend it ;)
<dark_light>
katatsumuri, i love lowercase_underscore, but the lowecase-with-dashes seemed very beautiful (some people sais it's common in lisp, and i currently worship all lisp-related things :)
<katatsumuri>
how about numbers?
<dark_light>
name1with1numbers? well..
<katatsumuri>
yes
<katatsumuri>
i wanted vector2 for a 2d vector type
<dark_light>
hmmm seems fine, but for separing words not
<katatsumuri>
no :-)
<katatsumuri>
pango: Are unit tests common with functional programming?
<katatsumuri>
pango: I found oUnit and tried it a little.
<dark_light>
here an indispensable function that i use, let rec loop f = f(); loop f isn't at the pervasives.. so i built an Lib.loop, and i use here Lib.loop my_predilete_function .. it's soooo beautyful.. i will never use while true do something after this!=)
<katatsumuri>
pango: But most people say that functional programs usually work when they compile.
<pango>
katatsumuri: unit testing seem to be orthogonal with programming paradigm choice
<pango>
katatsumuri: and the latter may less depend on functional paradigm than on strong typing (for OCaml at least)
<pango>
strong static typing even
<katatsumuri>
ok
<katatsumuri>
static typing seems to be the thing :-)
<pango>
dark_light: try the y combinator, it's more general :)
<dark_light>
y?
<katatsumuri>
i am just glad i made my main loop with a recursive call! :-D