nikki93 has quit [Remote host closed the connection]
nikki93 has joined #ocaml
arquebus has joined #ocaml
steshaw has quit [Read error: Connection reset by peer]
Drup has quit [Quit: Leaving.]
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
talzeus_ has quit [Remote host closed the connection]
talzeus_ has joined #ocaml
csakatoku has joined #ocaml
shinnya has quit [Ping timeout: 248 seconds]
talzeus_ has quit [Ping timeout: 240 seconds]
nikki93 has quit [Remote host closed the connection]
boogie has quit [Remote host closed the connection]
zamn has joined #ocaml
<zamn>
hi, can someone help me debug this syntax error I am receiving? http://pastebin.com/C190MjFp - On linle 6 i get: this expression has type 'a list but an expression was expected of type unit
<zamn>
i can't seem to figure out what i'm doing wrong
talzeus_ has joined #ocaml
nikki93 has joined #ocaml
maufred has joined #ocaml
zamn has quit [Quit: leaving]
hmmh has joined #ocaml
jpdeplaix has joined #ocaml
strobegen has joined #ocaml
hmmh has quit [Quit: ...]
breakds has joined #ocaml
cesar_ has joined #ocaml
cesar_ is now known as Guest74984
boogie has joined #ocaml
Guest74984 has quit [Ping timeout: 246 seconds]
breakds has quit [Remote host closed the connection]
boogie has quit [Remote host closed the connection]
<nikki93>
was experimenting with 'continuation passing' stuff using fold_left, thought this was cool
boogie has joined #ocaml
<nikki93>
(thus this is also tail-recursive... grows on heap though because closures)
ollehar has quit [Ping timeout: 272 seconds]
justdit has joined #ocaml
arquebus has quit [Quit: Konversation terminated!]
derek_c has joined #ocaml
justdit has quit [Remote host closed the connection]
justdit has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
justdit has quit [Read error: Connection reset by peer]
justdit has joined #ocaml
Simn has joined #ocaml
ulfdoz has joined #ocaml
gour has joined #ocaml
yacks has joined #ocaml
ulfdoz has quit [Ping timeout: 246 seconds]
mcclurmc has quit [Ping timeout: 256 seconds]
ulfdoz has joined #ocaml
csakatok_ has joined #ocaml
csakatoku has quit [Ping timeout: 248 seconds]
justdit_ has joined #ocaml
justdit has quit [Ping timeout: 264 seconds]
justdit_ has quit [Read error: Connection reset by peer]
paolooo has joined #ocaml
justdit has joined #ocaml
boogie has quit [Remote host closed the connection]
cesar_ has joined #ocaml
cesar_ is now known as Guest21386
csakatok_ has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 246 seconds]
Guest21386 has quit [Remote host closed the connection]
Neros has quit [Ping timeout: 240 seconds]
tobiasBora has joined #ocaml
tobiasBora has quit [Client Quit]
Yoric has joined #ocaml
q66 has joined #ocaml
thomasga has joined #ocaml
csakatoku has joined #ocaml
csakatoku has quit [Remote host closed the connection]
thomasga1 has joined #ocaml
thomasga has quit [Read error: Connection reset by peer]
csakatoku has joined #ocaml
thomasga1 has quit [Ping timeout: 252 seconds]
ttamttam has joined #ocaml
zpe has joined #ocaml
nisstyre has quit [Read error: Connection timed out]
zpe has quit [Read error: Connection reset by peer]
zpe has joined #ocaml
mika1 has joined #ocaml
derek_c has quit [Ping timeout: 246 seconds]
derek_c has joined #ocaml
justdit_ has joined #ocaml
justdit has quit [Read error: Connection reset by peer]
skchrko has quit [Quit: Leaving]
yezariaely has joined #ocaml
q66 has quit [Ping timeout: 268 seconds]
nikki93 has quit [Remote host closed the connection]
ggole has joined #ocaml
yacks has quit [Quit: Leaving]
talzeus_ has quit [Read error: Connection reset by peer]
talzeus_ has joined #ocaml
rwmjones has quit [Ping timeout: 264 seconds]
Yoric has quit [Ping timeout: 248 seconds]
radditz has joined #ocaml
rwmjones has joined #ocaml
q66 has joined #ocaml
Kakadu has joined #ocaml
justdit_ has quit [Read error: Connection reset by peer]
Kakadu has quit [Ping timeout: 272 seconds]
mort___ has joined #ocaml
Kakadu has joined #ocaml
bnoordhuis has joined #ocaml
mfp has joined #ocaml
Gabuzo4426 has joined #ocaml
AltGr has joined #ocaml
Gabuzo4426 has quit [Client Quit]
derek_c has quit [Quit: Lost terminal]
<radditz>
HI
bnoordhuis has quit [Ping timeout: 272 seconds]
bnoordhuis has joined #ocaml
ocp has joined #ocaml
avsm has joined #ocaml
Yoric has joined #ocaml
wolfnn has joined #ocaml
skchrko has joined #ocaml
<jyeo>
i am trying to change the order that ocamlbuild generates the camlp4 command line argument. is there anyway to do that?
<jyeo>
e.g camlp4 'pa_X.cma' 'pa_Y.cma' myfile.ml
<jyeo>
gets changed to camlp4 'pa_Y.cma' pa_X.cma' myfile.ml
<jyeo>
changing the order in the _tags file isn't working for me :-/
<radditz>
jyeo: have you tried sudo rm - rf / ?
<adrien_oww>
...
<jyeo>
radditz: why not you try that and tell me what happens?
<radditz>
jyeo: it fixes the camlp4 order
<jyeo>
awesome
<adrien_oww>
radditz: anything else to add?
<jyeo>
adrien_oww: let's be civil and not feed the troll. I don't wanna lose further faith in humanity.
<radditz>
jyeo: do you have a specific way to change order? you always have to change the first argumetn with the second?
<radditz>
jyeo: I don't know how they are generated, but is there a logical order you need? that is easily identifiable?
_andre has joined #ocaml
<jyeo>
apparently, camlp4 reads the cma files from right to left. it works with a particular order but not the other way around
<jyeo>
radditz: by the way, I am seriously wondering if u are asking a genuine question
<radditz>
well IDK how it works,. but would it be a reasonable solution to make your own camlp4 script that changes the order and calls the true camlp4 command? by changing the PATH maybe ?
<jyeo>
radditz: na, that defeats the purpose of using ocamlbuild in the first place. i want ocamlbuild to find my packages without specifying too many things.
<jyeo>
i can use a custom makefile to do that but i have to specify the location of my packages, etc
justdit has joined #ocaml
<jyeo>
that's not very portable :-/
<radditz>
excuse my ignorance, what exactly changes the order of the files? your build still succeeds?
<radditz>
I mean what change does the order of the camlp4 parameters imply?
<jyeo>
it reads the cma files in a different order
<radditz>
and that means...?
ivan\ has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
justdit has quit [Read error: Connection reset by peer]
justdit has joined #ocaml
sepp2k has joined #ocaml
<jyeo>
radditz: I get this error when it's read in the wrong order
<jyeo>
Camlp4: Uncaught exception: DynLoader.Error ("/Users/mapleleaf/.opam/system/lib/pa_debug_lib/pa_debug_syntax.cma", "error while linking /Users/mapleleaf/.opam/system/lib/pa_debug_lib/pa_debug_syntax.cma.\nReference to undefined global `Pa_deriving_common'")
<jyeo>
pa_debug depends on pa_deriving
<radditz>
jyeo: isn't there a depencency resolution?
<radditz>
I assumed there was a program to fix dependencies ?
<jyeo>
i am not sure how to do that :-/
<radditz>
I think for most of them ocamlbuild does it automatically, but there is a special ocamlbuild "makefile" that declares them, no?
<radditz>
strange the documentation says that dependencies are automatically resolved
<radditz>
adrien_oww: is it true?
<jyeo>
i am hoping someone who is more experienced with ocamlbuild can answer me. :-/
<radditz>
jyeo: I always assumed that you do ocamlbuild mainfile and dependencies are resolved
<jyeo>
not really.
<jyeo>
radditz: when you deal with camlp4 and ocamlfind packages, things get a lot hairier.
<jyeo>
ocamlbuild does not resolve dependencies between ocamlfind packages
<radditz>
right
<radditz>
well adrien_oww knows the answer, you can bug him and he will eventually answer
<radditz>
adrien
<radditz>
adrien
<radditz>
adrien
<radditz>
say his name 3 times to summon him
<radditz>
contempt: companion_cube companion_cube
<radditz>
you can also name an alternative program that does this in another language for bonus motivation points
<radditz>
OMG ocamlbuild doesn't allow me to manually generate dependencies, but ant totally does, I thought ocaml was better than that?
<radditz>
and to think ant wasn't even made by researchers
<radditz>
I am totally dissapointed guys
<whitequark>
I think ocamlfind should be resolving the deps
<radditz>
jyeo: maybe you have to add them to your ocaml libs directory for ocamlbuild to detect them?
iZsh has quit [Excess Flood]
csakatoku has quit [Remote host closed the connection]
dsheets has joined #ocaml
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
radditz has quit [Ping timeout: 250 seconds]
w0rm_x has joined #ocaml
breakds has joined #ocaml
ivan\ has joined #ocaml
Kakadu has quit [Ping timeout: 250 seconds]
steshaw has joined #ocaml
bnoordhuis has quit [Ping timeout: 245 seconds]
steshaw has quit [Remote host closed the connection]
steshaw has joined #ocaml
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
Kakadu has joined #ocaml
paolooo has quit [Quit: Page closed]
avsm has quit [Quit: Leaving.]
mlh has quit [Ping timeout: 252 seconds]
jbrown has quit [Remote host closed the connection]
ocp has quit [Ping timeout: 245 seconds]
Drup has joined #ocaml
talzeus_ has quit [Remote host closed the connection]
talzeus_ has joined #ocaml
talzeus_ has quit [Ping timeout: 272 seconds]
bnoordhuis has joined #ocaml
iZsh has joined #ocaml
_5kg has quit [Ping timeout: 272 seconds]
fryguybob has quit [Remote host closed the connection]
justdit has quit [Ping timeout: 252 seconds]
justdit_ has joined #ocaml
radditz has joined #ocaml
<radditz>
jyeo: did you findd the solutiomn?
<jyeo>
radditz: yep, sort of
<radditz>
jyeo: mind sharing it?
<jyeo>
radditz: I have a myocamlbuild.ml file that was controlling the arguments to camlp4
<radditz>
jyeo: so you manually give the order?
<jyeo>
i removed the myocamlbuild.ml file and it worked
<jyeo>
the myocamlbuild file was screwing up the order
<jyeo>
zzzz
<jyeo>
i didn't know that until i tried to compile my file in another directory
<radditz>
so ocamlbuild can find dependencies by itself?
bnoordhuis has quit [Ping timeout: 268 seconds]
<radditz>
jyeo: so now you have no build.ml at all? what is the use of myocamlbuild.ml anyway?
<jyeo>
AFAIK, it's to do some crazy fine tuning of the build automation. you can customize more things.
<adrien_oww>
jyeo: ah; where is that myocamlbuild.ml file from?
mchqwerty has joined #ocaml
<jyeo>
adrien_oww: oasis. I was compiling a library in the same directory. I use oasis to make it 'ocamlfindable'
<adrien_oww>
ah
<adrien_oww>
I wouldn't have expected issues but I can see this go wrong
breakds has quit [Remote host closed the connection]
thomasga has joined #ocaml
<jyeo>
yes. I took a week to fix this bug.
darkf has quit [Quit: Leaving]
<radditz>
jyeo: what do you mean in the same directory? as the source code?
<jyeo>
yes
<radditz>
jyeo: I don't understand why that didn't work, I assumed it was because of the myocamlbuild file
<jyeo>
ocamlbuild reads the myocamlbuild.ml first before doing build automation stuff
<radditz>
jyeo: so why can't you remove the file and compile in the same directory?
<jyeo>
radditz: yep, that's what I did.
<radditz>
jyeo: oh ok
<jyeo>
it's fixed now
<jyeo>
thanks radditz
<radditz>
jyeo: I don't think I helped you, no need to thank me
<jyeo>
come on, i'm just being polite :P
BitPuffin has joined #ocaml
talzeus_ has joined #ocaml
<radditz>
jyeo: thank you
Enjolras has joined #ocaml
avsm has joined #ocaml
jbrown has joined #ocaml
jbrown has quit [Ping timeout: 272 seconds]
talzeus__ has joined #ocaml
jbrown has joined #ocaml
avsm has quit [Quit: Leaving.]
talzeus_ has quit [Ping timeout: 260 seconds]
djcoin has joined #ocaml
bnoordhuis has joined #ocaml
avsm has joined #ocaml
justdit_ has quit [Ping timeout: 246 seconds]
jbrown has quit [Read error: Operation timed out]
saml has quit [Quit: Leaving]
mcclurmc has joined #ocaml
ollehar has joined #ocaml
saml has joined #ocaml
jbrown has joined #ocaml
amirmc has joined #ocaml
paolooo has joined #ocaml
shinnya has joined #ocaml
ocp has joined #ocaml
cesar_ has joined #ocaml
cesar_ is now known as Guest49414
ocp has quit [Read error: Operation timed out]
jbrown has quit [Ping timeout: 245 seconds]
justdit has joined #ocaml
Guest49414 has quit [Remote host closed the connection]
boogie has joined #ocaml
Kakadu_ has joined #ocaml
avsm has quit [Quit: Leaving.]
w0rm_x has quit [Ping timeout: 245 seconds]
<companion_cube>
radditz: ?
<radditz>
companion_cube: ?
<companion_cube>
you hl me :p
<Kakadu>
?
ocp has joined #ocaml
<companion_cube>
ocp: hey, your team ignores my opam pull request :p
demonimin has quit [Ping timeout: 240 seconds]
radditz has left #ocaml []
radditz has joined #ocaml
<radditz>
companion_cube: accident
<radditz>
I left by accident
<radditz>
companion_cube: contempt cthuluh
justdit has quit [Quit: Lost terminal]
mchqwerty has quit [Ping timeout: 245 seconds]
ollehar has quit [Quit: ollehar]
Kakadu_ has quit [Ping timeout: 240 seconds]
yacks has joined #ocaml
demonimin has joined #ocaml
radditz has left #ocaml []
rand000 has joined #ocaml
<AltGr>
companion_cube, hmm, the opam-repository maintainers are not exactly the OCamlPro team, although there is a non-void intersection.
<AltGr>
1.1 PRs should now be safe though
<companion_cube>
hmm, right, there are people at cambridge too?
<companion_cube>
AltGr: really? hope mine will pass then ;)
<AltGr>
1.0 clients are now stuck on the opam-1.0 branch :)
paolooo has quit [Ping timeout: 250 seconds]
cesar_ has joined #ocaml
cesar_ is now known as Guest48696
Yoric has quit [Ping timeout: 268 seconds]
dsheets has quit [Quit: Leaving]
Guest48696 has quit [Remote host closed the connection]
nikki93 has joined #ocaml
<thomasga>
companion_cube: I've just pulled your PR
nikki93 has quit [Ping timeout: 240 seconds]
<companion_cube>
thank you
yezariaely has quit [Quit: Leaving.]
Xenasis has joined #ocaml
<jpdeplaix>
thomasga: now that we are forced to use the new url as the default repository, is it updated as quickly as the git is ?
<jpdeplaix>
I changed the url of the default repository to take the git
<AltGr>
jpdeplaix, as before, it's updated every hour
amirmc has quit [Quit: Leaving.]
<jpdeplaix>
:(
avsm has joined #ocaml
<companion_cube>
would be nice (and motivating) to have some opam-bot on this chan
<companion_cube>
to announce new releases
<AltGr>
wow, that could quickly get noisy ;)
<companion_cube>
if it's every hour, it's ok, right?
<companion_cube>
it's not as if it would interrupt many discussions
<jpdeplaix>
there is already such a bot on #ocamlpro
<jpdeplaix>
(kind of)
amirmc has joined #ocaml
<companion_cube>
I don't know whether people here would be disturbed by the bot here
<companion_cube>
anyway, have to leave
<nicoo>
See you, C³
<adrien_oww>
?
<adrien_oww>
nah, avoid news every hour; it gets annoying quickly
<adrien_oww>
CIA bots are nice as long as they don't write infrequently
<pippijn>
a list of objects that you no longer use, and when you request an object and there are free objects, you return one and pull it off the list instead of allocating a new one
<pippijn>
useful mostly for large objects
<Drup>
BitPuffin: no, I mean that it it's allow "normally", then the gc will have to handle this case and may be penalized by doing so. To allow something that are not very useful (even if you don't agree, you just don't know what you are talking about), you penalize everyone else
<Drup>
and this is a bad compromise.
<pippijn>
you don't need to use a list, you can use an array to store the references
stevej has quit [Read error: Connection reset by peer]
skchrko has quit [Ping timeout: 260 seconds]
<pippijn>
when you're done with an object, you stuff it into the list
<mrvn>
which makes the GC slower for no reason
<BitPuffin>
pippijn: cool technique
<ggole>
Everything has to be mutable for that to work
<pippijn>
ggole: correct
<pippijn>
mrvn: possibly
<ggole>
And it isn't necessarily faster, since you get a write barrier hit
<pippijn>
ggole: correct
<pippijn>
but it *can* be faster
<ggole>
But it... right
<pippijn>
and it can be quite a lot faster, too
<ggole>
It might be profitable or even necessary in some situations
<pippijn>
especially when your object contains mostly ints
<pippijn>
because then you don't have the write barrier
stevej has joined #ocaml
<ggole>
You can rewrite things as arrays of immediate values, too
<ggole>
To get rid of pointers and allocations
<pippijn>
right
<ggole>
Although this is writing Fortran in OCaml, and is a pretty desperate move
<pippijn>
but that can easily become unmaintainable
<pippijn>
I haven't done that
<ggole>
If the patterns are right you can hide the junk underneath modules
<Drup>
pippijn: did you actually need this technique in reality ?
<pippijn>
Drup: yes
<pippijn>
and it helped
<Drup>
your parser ?
<ggole>
Ie, module Foo type t = int ... end
<pippijn>
yes
<BitPuffin>
Drup: Well but like I said it shouldn't be a preferred solution, just _a_ solution. And the GC shouldn't even get to know about it
<Drup>
yeah, quite a special case
bnoordhuis has quit [Ping timeout: 245 seconds]
<BitPuffin>
Drup: I is best avoided, but should not be forbidden
<BitPuffin>
it
<BitPuffin>
*
<pippijn>
it isn't forbidden
<pippijn>
you can implement your own memory model on int arrays
<BitPuffin>
I guess
<BitPuffin>
Should work
<pippijn>
but really, don't do that unless you *really* have to
<BitPuffin>
I guess it isn't too hard to just bind alloc etc.
<BitPuffin>
pippijn: exactly
<BitPuffin>
I'm not asking to do it really
<BitPuffin>
I just want to know that I have the option
<pippijn>
sure, you can use BigArray
<pippijn>
for blocks of C memory
<BitPuffin>
and wanted to check how much ocaml would get in the way if I ever needed to do that
<ggole>
Hmm, could int64 arrays/records use the float array representation?
<mrvn>
then compare fails and I guess get/set breaks
<pippijn>
mrvn: how?
<ggole>
Oh, compare. Right.
<pippijn>
why does compare fail?
<mrvn>
in polymorphic functions
<ggole>
I don't think access would be a problem though
<ggole>
Because compare looks at the tags and thinks "oh, an array of floats".
<Drup>
BitPuffin: I really doubt you will need it. Tweaking the GC will probable prove far more fruitful.
<BitPuffin>
Drup: Yep
<mrvn>
ggole: polymorphic get/set would detect the double array tag and then store the int64 as float.
<Drup>
probably*
<pippijn>
ah
<BitPuffin>
Drup: I will always prefer trying to work with the GC
<pippijn>
ok
<ggole>
mrvn: they are the same size, so it should be fine
<ggole>
(Unless I'm missing something)
<pippijn>
I think that will work
<mrvn>
hmm, maybe
<ggole>
They only place where you need type specific instructions (movsd, etc) are the places where you already know the type
<pippijn>
and float comparison is also done with ==, isn't it?
<ggole>
But, compare.
mort___ has quit [Ping timeout: 272 seconds]
<pippijn>
ah, with <
<mrvn>
but read the recent thread about a different GC header format on the list for a better solution
<pippijn>
yeah, you might get NaN or Inf accidentally
skchrko has joined #ocaml
<pippijn>
yes, giving it an Int64-array-tag would be better
jbrown has joined #ocaml
nikki93 has joined #ocaml
wolfnn has quit [Read error: Operation timed out]
avsm has quit [Quit: Leaving.]
amirmc has quit [Quit: Leaving.]
stevej has quit [Read error: Connection reset by peer]
jakub has joined #ocaml
stevej has joined #ocaml
ollehar has joined #ocaml
manizzle has joined #ocaml
<jakub>
Hi! I want to write a function which splits list of numbers into odd and even ones but without using tail recursion. Here is what i have already done: http://pastebin.com/d1gKg2iT but i think it can be done better. The main problem is: how to easly get to the lists contained in tuple returned from function. What is the easiest way to do this?
<mrvn>
better would be tail recursion
<ggole>
I take it this is homework: otherwise, List.partition is right there
<Drup>
jakub: why "without using tail recursion" ? :p
<mrvn>
jakub: use pattern matching
<mrvn>
jakub: let (even, odd) = split t in
<jakub>
ggole: you;re right, my task is to write two version, the one using tail recursion and the one without tail recursion and then to compare this two versions
<Drup>
oh
<Drup>
then, your version is fine.
<Drup>
you can simplify a bit the part on next, by removing k_1 and k_2 and using the pattern matching directly
<Drup>
this syntax : let (x,y) = z in ... is allowed.
<mrvn>
jakub: let rec split list = match list with ---> let rec split = function
<ggole>
k_1 and k_2 are also already available as fst and snd
amirmc has joined #ocaml
<mrvn>
jakub: are you allowed to use List.fold_*?
<jakub>
mrvn: i guess no
<mrvn>
figures
<mrvn>
jakub: if you add a linebreak before "then" you get better indentation too
ocp has quit [Ping timeout: 245 seconds]
<jakub>
mrvn: really? then is ussualy put on it's own line? just one word? :)
<pippijn>
or, I'm not sure whether the current implementation does
<pippijn>
but there was something like that
manizzle has joined #ocaml
<ggole>
Yep, I remember Appel going on about how stacks weren't any better
<ggole>
Which seems suspicious to me
<Xenasis>
If I had a list of size Y, which I'd want to split into a list of lists (where the internal lists are of size X), how would I do that?
happy4crazy has joined #ocaml
<def-lkb>
I would do that with to functions: one "split: int -> 'a list -> 'a list * 'a list" where in "head, tail = split n l", split the list l into an head of size at most n and a tail with the remaining items
<def-lkb>
two functions*
happy4crazy has quit [Remote host closed the connection]
<def-lkb>
The second one would just repeat "split" until the tail is empty
<Xenasis>
hmmm
<mrvn>
.oO(get List.nth, get List.tl, Obj.magic the first into a record with mutable second field and set it to [], repeat with second)
<ggole>
Soley because the gc might copy around the objects, so you need to keep a pointer to each one (over a call which might GC: you can make accesses directly until then, I guess).
<ggole>
def-lkb: ah, that's a good argument
<def-lkb>
Xenasis: my implementation goes wrong if the integer argument is negative
<def-lkb>
or null :)
<Xenasis>
Right
<Xenasis>
Honestly, this isn't even the function I need, but I sort of didn't want to ask for some implementation straight up :P
<Xenasis>
So I asked for something similar so I can find out more about these sorts of things!
<Xenasis>
Now hopefully I can figure it out myself
<def-lkb>
You're welcome.
<Xenasis>
I did say thanks :$
<Xenasis>
but yeah, thanks again
<def-lkb>
:)
Drup has joined #ocaml
Yoric has joined #ocaml
MoHaX has joined #ocaml
<nicoo>
Why do people keep wanting to use unsafe coercion ?
<def-lkb>
Sometimes the typer need external hints to do ist job :'
<def-lkb>
its*
<Drup>
an unsafe coercion is not an hint, it's "shut up, I know better than you"
<pippijn>
some programs can't be typed in ocaml
mort___ has joined #ocaml
q66 has quit [Quit: Leaving]
q66 has joined #ocaml
<Drup>
I didn't say it can't be true :)
MoHaX has quit [Quit: Leaving]
amirmc has joined #ocaml
<Drup>
and mrvn, I really hope you are not a teacher irl, because even if you are probably full of good will, you are a terrible at explaining stuff.
ggole has quit []
mort___ has quit [Quit: Leaving.]
<rks`>
Drup: and you are a terrible at englishing stuff
<rks`>
;)
<jpdeplaix>
:DDD
<companion_cube>
gentlemen! no fighting in the war room!
_andre has quit [Quit: leaving]
amirmc has quit [Quit: Leaving.]
* nicoo
hugs companion_cube
<nicoo>
pippijn: Yes. And I believe that often, those are programs that we are better off not writing
<pippijn>
nicoo: like parsers?
<pippijn>
nicoo: and foreign function interfaces?
mort___ has joined #ocaml
<nicoo>
extern isn't really magic (but you can easily build magic with it). And yes, Obj.nagic has its uses. But what I meant is that there seem to be some kind of “unhealthy fascination” around Obj.magic.
<nicoo>
I mean, gaining local mutability to make a function tail-recursive and more efficient isn't the kind of micro-optimization we should use all over the place.
<companion_cube>
I've seen some reasonable uses of it
<companion_cube>
btw, it would be nice to have algebraic types with mutable fields
Yoric has quit [Ping timeout: 259 seconds]
w0rm_x has joined #ocaml
<pippijn>
Drup: were you the guy who thinks jabber is great?
<Drup>
quite possibly
<Drup>
not necessarily great, but far better than IRC.
<pippijn>
I switched from irc to xmpp mostly for one reason
<pippijn>
when I'm talking to someone on irc, and their connection times out, my last N messages (where N is unknown) are lost
<Drup>
don't worry, it's far worst when you are on the other side of the bad connection.
<companion_cube>
oh, well, irc still works
<pippijn>
and I thought xmpp has this
<pippijn>
guaranteed message delivery
<pippijn>
in fact, though that might be an implementation bug, this is not the case
<Drup>
you can't "garantee" in a sense you are not sure that the other guy will ever reconnect.
<pippijn>
fine
<pippijn>
I'm not up for splitting hairs right now
<pippijn>
either way
nikki93 has quit [Remote host closed the connection]
<Drup>
but the delay for a timeout to be noticed is very short, compared to irc, and (if the client and the server implement it) you have offline messages
<companion_cube>
lazy (split hairs)
<pippijn>
what happens is: messages that are sent when the other person is currently timeouting are lost
<pippijn>
with prosody xmpp server
mort___ has quit [Quit: Leaving.]
<Drup>
and inside a channel, you have the X last messages replayed on connection to the chan.
<pippijn>
I'm using it primarily for one on one communication
<Drup>
companion_cube: on the "irc still works" stuff, yes, Java and C++ too. :D
<companion_cube>
nah
<companion_cube>
anyway, it's a network effect (!), it needs everyone to change for the change to work
Yoric has joined #ocaml
ocp has joined #ocaml
zamn has joined #ocaml
Yoric has quit [Ping timeout: 245 seconds]
<zamn>
hi, can anyone helpme with this code? for some reason I keep getting "got 'a list list but expected int list". It's my contains() call inside of eval_move(). http://www.zamn.net/puzzle.txt
<companion_cube>
for some reason I can't load the page
<companion_cube>
but you most likely have some extra "[ ]"
<zamn>
still can't?
<zamn>
i'd pasetbin but im on a tablet right now so i dont have a mouse -_-
<pippijn>
the server doesn't keep messages, but the client does
<zamn>
(the one i pasted above)
<pippijn>
so messages can only be exchanged when both are online
<pippijn>
which is necessary due to end to end encryption
<pippijn>
which is a good thing™
<pippijn>
but I think skype doesn't have end to end encryption (anymore)
<mrvn>
zamn: you want type (int list list * int list list * int) -> ...?
<pippijn>
Drup: yes, namely when the connection times out
<pippijn>
Drup: it might be a server bug, though
<pippijn>
maybe xmpp is not to blame
<zamn>
mrvn: i want b to be int list list, endlist to be int list list
<zamn>
i'm iterating through b which is supposed to iterate through each inner list
<mrvn>
zamn: you are aiming to make this tail recursive?
<zamn>
mrvn: i'm just trying to solve this x_x
<zamn>
mrvn: as long as the head isnt in the endlist then i want to keep going on that head
<mrvn>
zamn: b is your list of possible next boards, endlist are the moves you did so far (list of boards).
<zamn>
yes
<Drup>
pippijn: be in a chanel completly solve the whole issue, but I'm not sure about 1-1 conversation, I don't use it that much
<mrvn>
zamn: so you recursively test all boards and when you have tested them all you return the list of moves you did so far?
<zamn>
yes!
<zamn>
is that wha tmy code says?
<zamn>
lol
<zamn>
thats what i tried writing.
<pippijn>
Drup: in a channel, I can't have end to end encryption
<mrvn>
that is line 323 and wrong
<Drup>
indeed
<zamn>
mrvn: i'm not sure what to do for an empty list
<mrvn>
zamn: you start with endlist = [start_board], right?
<pippijn>
I want that, so I need a 1-1 conversation
<zamn>
yes
<mrvn>
zamn: so your eval_moves would do a lot of recursive things and then return [start_board]
<zamn>
well, the end goal is to never run into the case where b is empty
<mrvn>
That isn't a solution for sure
<zamn>
i just put that to make it shut up about wranings
Yoric has joined #ocaml
<mrvn>
zamn: use assert false
<zamn>
okay but i still have that error after putting that
<pippijn>
in skype, the messages are kept by the sending client and when establishing a communication channel, the clients somehow exchange information on which messages have been received and which have not
<mrvn>
ok, other pattern
<mrvn>
h is the next possible board and t the remaining possibilities.
<pippijn>
so if you have two receiving clients on different computers, you can still get all the messages the sending client knows about, even when they are not logged in at the same time
<zamn>
mrvn: yes t are the remaining possiblilities
<pippijn>
xmpp also doesn't seem to broadcast private messages to all presences
<zamn>
ah i see, i never actually iterate through t
<mrvn>
zamn: is_sorted h only makes sense if n == 0
<zamn>
no because there can be solutions <= n
<zamn>
i want to stop when i've gone >= n times
<mrvn>
that would be stupid, then you called it with a too big n. I'm assuming at the end you will try to solve it for n=1,2,3,4,5, till you get a solution.
<mrvn>
and the exercise asks for "Given board b, return all solutions of length n"
<zamn>
you said moves was all the possible moves x_x
<mrvn>
zamn: all the next moves. Not overall all moves
<zamn>
oh okay
<zamn>
you're basically doing this from the end to the beginning it seems
<zamn>
like the case where we have the list with all the boards that lead up to that solution
Simn has quit [Quit: Leaving]
<mrvn>
that is usualy how you learn it. Think factorial. You first define factorial(1), then the n -> n-1 recursion.
<zamn>
okay
<mrvn>
have you thought about what to do with t in line 5?
<zamn>
you mean moves?
<zamn>
basically im just confused as to what youre doing
<zamn>
we are looping through moves and and checking if eahc move is sorted
<zamn>
if it is then we append that move to the endlist
<zamn>
but we want _all_ the moves up to that point as well
<mrvn>
zamn: the eval_moves will do the recursion and try all possible move combinations. The check_solution checks if the current move sequenze in endlist can be completed to give a sorted board.
<zamn>
how can it determine that though?
<mrvn>
zamn: if any of the moves is sorted then you have a solution.
<zamn>
so we only care about th eheads then
<zamn>
cause cause the solutions will always be the last list insid eof the list
<mrvn>
zamn: no. any one of the moves might be sorted.
<zamn>
yeah but then we need to make a new list from that point onwards
<mrvn>
the [move::endlist]?
<zamn>
yeah but thats just appending the sorted list to the endlist
<zamn>
we need to show th eprocess
<zamn>
i.e. the boards up to sorted board
<mrvn>
that is in endlist
<zamn>
okay
<zamn>
that makes sense then
<mrvn>
endlist are the boards you used to get here
<zamn>
oh
<zamn>
and moves is just the possible moves i *could* make form this point onwards
<zamn>
when i try doing: [1;2;3]::[4;5;6] on the ocaml interpreter i get an error
<zamn>
so could that line possibly be wrong
<mrvn>
shouldn't matter. its basic stuff thats been stable for decades.
<mrvn>
[1;2;3]::[[4;5;6]]
<mrvn>
board::boards
<zamn>
ah yeah that works..
<zamn>
wtf
<mrvn>
what is the type for check_solution?
<zamn>
- : 'a list list * 'a list list -> 'a list list list = <fun>
<mrvn>
that is correct
<mrvn>
can't be returning a list of ints then
<zamn>
oh
<zamn>
hm
<zamn>
# let b = [1; 0; 2; 3];; make_moves(b)
<zamn>
that wont even print out make_moves
<mrvn>
let m = make_moves(b);;
<zamn>
ah okay
<zamn>
OK
<zamn>
now it works
<zamn>
# check_solution(make_moves(b), [b]);;
<zamn>
- : int list list list = [[[0; 1; 2; 3]; [1; 0; 2; 3]]]
Yoric has quit [Read error: Connection reset by peer]
<mrvn>
Ok, back to eval_moves.
<zamn>
thanks for this btw mrvn
<zamn>
you are saving me ~_~
<mrvn>
I would do "if n <= 0 then check_solution.... else check_moves ...."
<mrvn>
n should never be negative but just in case lets catch that there too
<zamn>
heh yeah i was trying to think of a case where it'd be negative
<mrvn>
can only be negative when you call it with a negative.
Anarchos has quit [Quit: Vision[0.9.7-H-280704]: i've been blurred!]
Yoric has joined #ocaml
<mrvn>
lets write the "test_moves" directly in eval_moves, because that needs to call eval_moves recursively.
<zamn>
okay
<zamn>
i actually tried to do circular recursion in one of my attempts heh
<zamn>
i had to use the and keyword
<mrvn>
b is the list of next moves you can do, endlist is the list of moves you have already done and n the number of moves you have left to solve the puzzle.
<zamn>
right now my test_moves(b, endlist, n) = if n <= 0 then check_solution(make_moves b, endlist) else check_moves(make_moves b, endlist)
<zamn>
and my check_moves kind of just takes each seperate move in make_moves b and appends it to endlist
<mrvn>
and calls test_moves again?
<zamn>
where would it do that
<zamn>
after my check_moves(..) ?
<mrvn>
in check_moves you have to go through all the moves and for each call test_moves(move, move::endlist, n-1)
<mrvn>
with some condition and handling the return values.
<mrvn>
just to get smething that has the right syntax
<zamn>
yeah
<mrvn>
yep. the eval_moves gives you all the solutions for the case you use move h, the check_moves gives you all the solutions for all the other moves in t. How do you combine the two?
<mrvn>
[s1;s2] and [s3;s4;s5;s6;s7;s8]
<zamn>
using ::
<zamn>
but i need to create another function don't i?
<zamn>
in order to hold both of those
<zamn>
[a;b]
<zamn>
like that
<mrvn>
:: adds one elemnt to a list. you have 2 lists
<zamn>
so i want to add one list to a list of lists
Yoric has quit [Read error: Connection reset by peer]
<zamn>
val check_solution : 'a list list * 'a list list -> 'a list list list = <fun>
<zamn>
val check_moves : int list list * int list list * int -> int list list list = <fun>
<zamn>
val eval_moves : int list * int list list * int -> int list list list = <fun>
Yoric has joined #ocaml
<mrvn>
zamn: any progress with solve_board?
Yoric has quit [Read error: Connection reset by peer]
<zamn>
not yet
<zamn>
i've been testing eval_moves
<zamn>
and im not sure if i'm just doing it wrong
<zamn>
or if it doesnt work
Yoric has joined #ocaml
<zamn>
eval_moves([1;2;0;3;4;5;6;7;8],[],2);;
<zamn>
returns []
<zamn>
am i doing it wrong -_-
<mrvn>
let b = [1;0;3;2];; let x = eval_moves(b, [b], 1);;
<zamn>
oh oops
<zamn>
# eval_moves(b, [b], 1);;
<zamn>
- : int list list list = []
<zamn>
yea even for b = [1; 0; 2; 3] i get []
strobegen has quit [Quit: Leaving.]
<mrvn>
let b = [0;1;3;2];; let x = eval_moves(b, [b], 0);; ?
<zamn>
# eval_moves(b, [b], 0);;
<zamn>
- : int list list list = [[[0; 1; 2; 3]; [1; 0; 2; 3]]]
<zamn>
that works for 1;0;2;3
<zamn>
let me try yours
<zamn>
i think the one you gave me is unsolvable
<zamn>
actually heh
BitPuffin has joined #ocaml
<zamn>
cause its returning []
Yoric has quit [Read error: Connection reset by peer]
<mrvn>
huh? Thats the example from above. just swap 2 and 3
<zamn>
yeah
<zamn>
thats what im saying with only using the 0 space to swap
<mrvn>
let m = make_moves b;;
<zamn>
- : int list list = [[1; 0; 3; 2]; [3; 1; 0; 2]]
<mrvn>
ok, lets move the 0 twice then: let b = [1;3;2;0];;
<mrvn>
let x = eval_moves(b, [b], 1);;
<mrvn>
swap 3/0, swap 1/0
Yoric has joined #ocaml
<zamn>
yea that works.
<mrvn>
what does it give?
<zamn>
- : int list list list = [[[0; 1; 2; 3]; [1; 0; 2; 3]; [1; 3; 2; 0]]]
<mrvn>
so it works
<zamn>
yes
<zamn>
thank you :D
<zamn>
so i just need to do n-1 in my solve_board
<mrvn>
Now write solve() and then save that for save keeping.
<mrvn>
Then you can make it better. e.g. fix that "n-1" issue.
<zamn>
its already amazing :D
<mrvn>
or in eval_moves you have b and endlist. The head of endlist is already b
<zamn>
ah yeah
<mrvn>
so you might make endlist one smaller.
rand000 has quit [Quit: leaving]
Yoric has quit [Read error: Connection reset by peer]
<mrvn>
in eval_moves when n <= 0 you could check if b is sorted instead of doing another make_moves.
wolfnn has quit [Ping timeout: 272 seconds]
Yoric has joined #ocaml
MoHaX has quit [Ping timeout: 272 seconds]
<mrvn>
and for extra credits in check_moves user an accumulator and append solutions to it as you find them instead of using @, make it tail recrusive.
<mrvn>
make use of the map and fold helpers
<zamn>
eh
<zamn>
something isnt right x_x
ocp has quit [Ping timeout: 245 seconds]
Yoric has quit [Read error: Connection reset by peer]
<mrvn>
how does your solve_board look like?
<zamn>
its 1 line
<zamn>
eval_moves(b, [b], n-1)
<mrvn>
should be right.
<mrvn>
let b = [1;3;2;0];; let x = eval_moves(b,2);;
Yoric has joined #ocaml
<mrvn>
let b = [1;3;2;0];; let x = solve_board(b, 2);; I mean
Yoric has quit [Read error: Connection reset by peer]
<zamn>
yeah that one is failing
<zamn>
for b = 3
<zamn>
er, n
<zamn>
oh because its supposed to be <= n
<zamn>
for the solution
<zamn>
we dont need n solutions
<zamn>
so i have to check_solutions after every check_moves
<mrvn>
that would probably not finish with your approach.
Yoric has quit [Read error: Connection reset by peer]
nikki93 has quit [Remote host closed the connection]
<mrvn>
zamn: That's just for comparison. Doesn't realy solve your exercise.
<zamn>
lol yeah
<mrvn>
wrote that years ago.
<zamn>
well you're my savior right now :D
<zamn>
except i have one more failure now
<mrvn>
well, enough saving for today, the bed is calling.
<zamn>
noo 1 more case x_x
nikki93 has joined #ocaml
<zamn>
i cant do it alonee
<mrvn>
zamn: good.
<zamn>
x_x
malo has quit [Quit: Leaving]
<mrvn>
I hate that he is teaching you foo(x,y) syntax. You shouldn't pass arguments as tuples. Its slower and breaks partial aplications.
<mrvn>
Its ocaml, not c.
<mrvn>
n8
<zamn>
night!
steshaw has joined #ocaml
<zamn>
thanks for the help :)
Yoric has joined #ocaml
caseyjames has joined #ocaml
<caseyjames>
I'm running toplevel in emacs. Is there anyway to 'open' a source from another file in the same directory? I tried #use "topfind";; #require "note";; but its giving me nothin