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/
Mr_Awesome has joined #ocaml
<Mr_Awesome> anyone know a quick way to get the last element of a list?
<TSC> reverse it and then take the head
<Mr_Awesome> ah, thanks
<Mr_Awesome> hmm, would getting the length and indexing that minus one be faster?
<TSC> I doubt it, but you can try
<TSC> Both take linear time
<Mr_Awesome> right, i guess it doesnt really matter
mrsolo_ has quit [Remote closed the connection]
<gonnet> (what about the memory cost ?)
<gonnet> if you first have to make a (reverse) copy, and then only take the first element, it will be worse than simply reading until the last element i guess
<TSC> I guess so too
<zmdkrbou> anyway, you shouldn't have to take the last element of a list
<gonnet> indeed, somewhat strange for a list
<gonnet> perhaps the algorithm can be rewritten if those are the only access that are done ?
<TSC> I had to do it recently, because I wanted the minimum and maximum values in a sorted list
<zmdkrbou> yes, that's not meant for it, either you take the head or do a recursion on it, but taking the last element ...
<zmdkrbou> mmmh TSC, there is List.sort :)
<TSC> Yes, the list was already sorted
<TSC> I wanted the two ends
<zmdkrbou> oh, misread
<gonnet> n log n gg zmdkrbou :)
<TSC> (:
<Mr_Awesome> well, i have a list of ints, and if my current int sequentially follows the last int in the list, i want to append it to the end
<gonnet> seems hard to avoid this then !
<zmdkrbou> TSC: did you sort it yourself ?
<gonnet> i guess not :)
<gonnet> would be a strange algorithme
<gonnet> -e
<Mr_Awesome> im searching for a straight in a poker hand
<TSC> zmdkrbou: No, the list was maintained in sorted order (it was the implementation of a set)
<zmdkrbou> ok
<Mr_Awesome> i suppose i could sort the list first, then step through and append only in the beginning
<gonnet> well, simplest ... go into the list ..
<zmdkrbou> Mr_Awesome: so your list is a poker hand ?
<gonnet> anyway it seems that you won't get anything better than n ops
<gonnet> n+1 seems not to hard to code
<zmdkrbou> if it's a poker hand, the list is soooooooo small that you really don't care about getting it reversed or what ...
<Mr_Awesome> zmdkrbou: is that a question?
<zmdkrbou> nope
<zmdkrbou> is your list fixed in length ?
<Mr_Awesome> no
<zmdkrbou> strange poker hand :p
<Mr_Awesome> range of 2-7
<zmdkrbou> huhu
<gonnet> not too long then :)
<zmdkrbou> so it's terribly small
<Mr_Awesome> think texas holdem or seven card stud
<zmdkrbou> first thing, you don't need to think about complexity with a list of max. 7 elements
<Mr_Awesome> yeah i know
<gonnet> it is all O(1) :)
<Mr_Awesome> im thinking about conciseness in code
<zmdkrbou> and you should use { card1 : bla ; card2 : bla ; etc. }
<Mr_Awesome> i should use a record? for what?
<zmdkrbou> (or not ... would be a bit strange to search in this record)
<zmdkrbou> because you don't need a variable length structure
<Mr_Awesome> but i do, like i said a range of 2-7
<zmdkrbou> you can take 7 and have a fake card representation
<Mr_Awesome> wouldnt a list be easier to work with though?
<zmdkrbou> yes
<Mr_Awesome> youre not very convincing ;)
<zmdkrbou> the simplest way is using a list and not thinking of complexity
<Mr_Awesome> right, im just trying to find a nice straightforward concise method
<zmdkrbou> because list are easy to work with, and with 7 elements you don't care at all what you do with it
<Mr_Awesome> right now, the method is kind of bloated
<zmdkrbou> List.hd (List.rev l) is ok
<Mr_Awesome> yeah, i guess so
<TSC> Or use "let last l = List.hd (List.rev l)", then it's even shorter!
<Mr_Awesome> i used "let last = List.hd (List.rev l)"
<Mr_Awesome> since im only doing it once
b00t has joined #ocaml
b00t has quit [Remote closed the connection]
b00t has joined #ocaml
<Mr_Awesome> anyone know a good way to get the first five elements of a list, without resorting to making a recursive function?
marcelino has joined #ocaml
marcelino has quit ["Ex-Chat"]
b00t has quit [Client Quit]
b00t has joined #ocaml
<Smerdy> Mr_Awesome, it's easy with pattern-matching.
Smerdy is now known as Smerdyakov
<Mr_Awesome> too late, i already wrote a list_sub function lol
<Mr_Awesome> yeah i just realized that
<Mr_Awesome> e1 :: e2 :: ... l would work
EsotericMoniker has quit ["Trillian (http://www.ceruleanstudios.com"]
pango_ has quit [Remote closed the connection]
shawn__ has quit [Connection timed out]
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
Mr_Awesome has left #ocaml []
shekmalhen has joined #ocaml
shawn__ has joined #ocaml
_velco has joined #ocaml
shekmalhen has quit ["dodo"]
shawn__ has quit ["This computer has gone to sleep"]
b00t has quit [Read error: 110 (Connection timed out)]
_velco has quit ["I'm outta here ..."]
Snark has joined #ocaml
pango has joined #ocaml
smimou has joined #ocaml
<pango> <gonnet> it is all O(1) :)
<pango> O() notation is about asymptotical limit, so it makes no sense using it in this case, on bounded arguments
shawn__ has joined #ocaml
love-pingoo has joined #ocaml
Axioplase has joined #ocaml
<Axioplase> Hi !
<Axioplase> I have a weird "bug..."
<Axioplase> in my file, I have "let ti = Unix.gmtime(Unix.gettimeofday()) in [blablabla]"
<Axioplase> and when I compile I get two different errors, according to what [blablabla] is.
<smimou> what are those errors?
<Axioplase> if it's the empty string, then the error is Error while linking emit.cmo: Reference to undefined global `Unix'
<Axioplase> if it's something using ti (to print the fields) I get : Unbound record field label tm_year
<Axioplase> (and so on if i remove the year label)
<pango> record fields are bound to their module namespace (Unix.tm_year, ...)
<pango> (record field names, I mean)
<pango> now, you should get undefined global `Unix' in all cases ;)
<love-pingoo> with the empty string, the compiler sees no error before linking, with your other expr an error occurs during compilation (did you mean Unix.tm_year ?).. that's not surprising to get different errors in such cases
<Axioplase> haaa.. I get it...
<Axioplase> ok thanks...
<Axioplase> Weird I find, but ogical indeed...
love-pingoo has quit ["Connection reset by pear"]
<pango> for your linking problem, you need to link against unix.cma (bytecode) or unix.cmxa (native)
<Axioplase> yep. That's what I m trying to do... (it s not my Makefile, and it's quite obfuscated for me ^^)
pango has quit ["bbl"]
slipstream-- has joined #ocaml
pango has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
Wild_Cat has joined #ocaml
Wild_Cat has quit [Client Quit]
shawn__ has quit [Read error: 110 (Connection timed out)]
shawn__ has joined #ocaml
smimou has quit ["bli"]
love-pingoo has joined #ocaml
Wild_Cat has joined #ocaml
finelemo1 has joined #ocaml
Axioplase has quit ["kore kara tabe ni iku ! (ca vous la coupe hein, bande de moules !)"]
sp00k has joined #ocaml
sp00k has left #ocaml []
finelemon has quit [Read error: 110 (Connection timed out)]
joshcryer has quit [Read error: 104 (Connection reset by peer)]
b00t has joined #ocaml
|Lupin| has joined #ocaml
<|Lupin|> Hello, all.
<|Lupin|> This is an OCaml/Windows question
<zmdkrbou> lo |Lupin|
<|Lupin|> We use a Cygwin version of OCaml
<|Lupin|> and it seems that dynamicloading isnotSupported
<|Lupin|> Is that right, and whatshould one do to avoid this obstacle, please ?
<|Lupin|> lo zmdkrbou
<ppsmimou> hi |Lupin|
<|Lupin|> hi ppsmimou
<|Lupin|> For instance
<|Lupin|> #load "unix.cma";;
<|Lupin|> doesn't work on Windows...
<ppsmimou> my only advice would be to use putty and do an ssh on a real box
<zmdkrbou> (hem)
<|Lupin|> that's not verysatisfactory, in fact...
b00t has quit [Remote closed the connection]
<|Lupin|> pango: Thanks !
<|Lupin|> Are ther users of OCaml under Windows here?
<|Lupin|> Which ofThe three solutions (MS, Mingw, Cygwin) is she mor frequently used ?
<|Lupin|> Or alternatively, how do you compile a progra usingThe Unix module in a way avoiding the need for dynamic loading, in byte-code ?
tennin has joined #ocaml
|Lupin| has left #ocaml []
Snark has quit [Read error: 110 (Connection timed out)]
Snark has joined #ocaml
love-pingoo has quit ["Leaving"]
tennin has quit [Read error: 113 (No route to host)]
dark_light has joined #ocaml
smimou has joined #ocaml
hcarty has joined #ocaml
hcarty has left #ocaml []
Wild_Cat has quit ["Leaving"]
|Lupin| has joined #ocaml
<|Lupin|> Hi again
<|Lupin|> A findlib question, now
<|Lupin|> On a Windows+Cygwin system:
<|Lupin|> ocamlc -version prints the right thing (3.09.2)
<|Lupin|> but ocamlfind ocamlc -version fails and prints nothing
<|Lupin|> Has somebody an ide wher this could come from ?
|Lupin| has left #ocaml []
love-pingoo has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
love-pingoo has joined #ocaml
pango has quit ["Leaving"]
love-pingoo has quit [Remote closed the connection]
pango has joined #ocaml
joshcryer has joined #ocaml
_jol_ has joined #ocaml
_JusSx_ has joined #ocaml
_jol_ has quit ["leaving"]
Snark has quit ["Leaving"]
shawn__ has quit ["This computer has gone to sleep"]
_JusSx_ has quit ["leaving"]
kral has joined #ocaml
kral has quit [Client Quit]
kral has joined #ocaml
mnemonic has joined #ocaml
kral has quit [Client Quit]
<mnemonic> hi
shawn__ has joined #ocaml
kral has joined #ocaml
kral has quit [Client Quit]
pango has quit [Remote closed the connection]
mnemonic has quit ["leaving"]
shawn__ has quit [Read error: 104 (Connection reset by peer)]
shawn__ has joined #ocaml
shawn__ has quit [Read error: 104 (Connection reset by peer)]
shawn__ has joined #ocaml
pango has joined #ocaml
Nanomon has joined #ocaml
<Nanomon> which editor/ide ocaml programmers use?
<ulfdoz> emacs/ocaml-mode
<zmdkrbou> vim
<zmdkrbou> (vim/omlet to reply to ulfdoz :p)
<smimou> nano
<nattfodd> echo and pipes
<ulfdoz> now you're kidding. ;)
<nattfodd> how did you guess? :)
Grincheux has joined #ocaml
<Grincheux> ed
<ulfdoz> I wondered, how you maintain your code.
Grincheux has left #ocaml []
<smimou> ulfdoz: actually vim wasn't a joke
<zmdkrbou> smimou: all other answers were jokes :p
<ulfdoz> I know, that vim is quite flexible, although not my taste.
<nattfodd> the your taste is bad
<nattfodd> ;)
<smimou> +n
<nattfodd> thanks
smimou has quit ["bli"]