<zmdkrbou>
your structure will only be made of Append ([a],l) and so on, you only use 1 element List. lists
<zmdkrbou>
Append ([a], Append ([a], Append ([a]), Nil), Nil), Nil) << this is a :: a :: a :: []
<Jeff_123_>
right
<Jeff_123_>
so what's wrong with that? It's very closelly related to a::a::a::[]
<Jeff_123_>
cept uh, a lot more [] :)
<zmdkrbou>
well, you don't get O(1) append with that thing, it's isomorphic to the List module
<zmdkrbou>
any you don't really have O(1) appends with your code, do you ? or in which case ? average, really ?
<zmdkrbou>
+way
<Jeff_123_>
do you mean like,
<Jeff_123_>
let example = cons 1 (cons 1 (cons 1 (cons 1 Nil)))
<Jeff_123_>
append example example?
<zmdkrbou>
well ok
<zmdkrbou>
your structure is ugly if you use your tail-rec cons
<Jeff_123_>
it ends up being Apply2 (example, example), which i figured would be O(1) (I'm no computer scientiest though)
<zmdkrbou>
and when you want to reach an element, it's not linear anymore
<Jeff_123_>
oh hm, I should try to add an equivalent of List.nth then
<zmdkrbou>
the problem is that the complexity of most of your operations depend on how the list was built
<zmdkrbou>
if it was build from small pieces (and to the extreme, from singletons), then it's awful
<zmdkrbou>
maybe it's ok on the average, but anyway there are some "privileged" operations that you want to do most of the time
<zmdkrbou>
append is not really one of them
<Jeff_123_>
depends on what you're doing
<zmdkrbou>
i'd like to see a piece of code where you use more append than you use any search function :)
<zmdkrbou>
mem, fold_left, iter ...
<zmdkrbou>
you don't put an element in a list just to ignore him afterwards :)
<Jeff_123_>
I haven't timed it, but fastlist.fold_left should be pretty quick
<Jeff_123_>
... I hope ;)
<Jeff_123_>
List.nth though, you gotta admit, that's a rarer one.
<Jeff_123_>
at least for me, I hardly use it
<zmdkrbou>
yes, it's a non-existent one for me :)
<zmdkrbou>
but i wonder what is the actual complexity of your operations
<Jeff_123_>
My hope was if only the library functions are used to construct the lists, they should be pretty good
<Jeff_123_>
I should write a little time function to get empirical data
<zmdkrbou>
well, "empirical data" is not that good :)
<Jeff_123_>
perhaps, but I don't want to go through and prove their worst-case and average-case complexity
<Jeff_123_>
I maybe could do it, but it'd take me al ong time
<Jeff_123_>
Like I said, I'm not a comp sci guy.
<Jeff_123_>
like is the old cons or the new cons better after the fact? I dunno, i was just responding to the not-tail-rec criticism :)O
<zmdkrbou>
my guess is that if there was an implementation of the list module with a better complexity, ocaml guys would have use it :)
<Jeff_123_>
maybe I invented something new though :)
<Jeff_123_>
Not likely, but maybe
<zmdkrbou>
*cough* *cough* :)
<Jeff_123_>
hehe
<zmdkrbou>
another way of getting O(1) append could be to use a more complex data structure, and hide it under a list interface
<Jeff_123_>
I never stated it, but I meant for the l type to be abstract, and then the user could get it via to_list
<Jeff_123_>
but perhaps that's not what you mean
<zmdkrbou>
yes, that's why you hide the complex structure under an interface which has the same functions as the List module
<zmdkrbou>
just like you're doing here
<zmdkrbou>
by the way, your structure is almost a tree
<zmdkrbou>
if you use your tail-rec cons for example, you get a very degenerated case
<zmdkrbou>
(that is, a list :p)
<zmdkrbou>
so folding should be quite similar to walking through a tree
<Jeff_123_>
fold can never be better than O(n) afaik
<zmdkrbou>
and to keep good average properties, you probably need to build a balanced tree ...
<Jeff_123_>
well you could always implement lists using module IntMap = Map.Make(type t int let compare = compare)
<Jeff_123_>
that might be fun
<zmdkrbou>
yes, and that would be a good implementation, depending on the type of operations you want to use
<zmdkrbou>
for append it's probably bad :(
<Jeff_123_>
Or you could implement lists via TCL lists through the labltk library
<Jeff_123_>
you
<Jeff_123_>
mt
<Jeff_123_>
Actually, I can't think of any operation that would be faster. Well, maybe nth.
<Jeff_123_>
but then just use arrays and be done with it
<zmdkrbou>
searching in a map is logarithmic in the size of the map
<zmdkrbou>
so it's better than searching in a list
<Jeff_123_>
You'd be searching by the integers n where n is the elements position in the list, so wouldn't it be the same?
<Jeff_123_>
So like, nth would be fast cause you're searching for the nth element, but any particular element... who knows where that is in the tree.
<Jeff_123_>
OH OH I have an idea.... map over some arbitrary type, and then have each element map to its positions in the list rather than having the positions in the list map to the elements. That'd even give you some automatic compression.
<Jeff_123_>
cons would be pretty fast... append would be slow, but search would be fast
<Jeff_123_>
map and fold would be pretty bad i imagine
netx has quit ["Leaving"]
JohnnyL has quit ["Leaving"]
sergez_ has quit []
buluca has quit [Read error: 113 (No route to host)]
david_koontz has quit []
mrsolo_ has joined #ocaml
<tsuyoshi>
I think I'm gonna patch the compiler so it inlines List/Array/String.iter
<Jeff_123_>
sounds like a plan
<tsuyoshi>
rewriting loops so they go faster is too annoying
mrsolo__ has quit [Read error: 113 (No route to host)]
jlouis has joined #ocaml
<Jeff_123_>
I like the idea of compiling caml to llvm, then it can take advantage of all of llvm's optimizations and backend.
buluca has quit [Read error: 113 (No route to host)]
mrsolo__ has joined #ocaml
olleolleolle has quit []
Jeff_123_ has quit [Read error: 104 (Connection reset by peer)]
jlouis_ has joined #ocaml
brooksbp has joined #ocaml
mrsolo_ has quit [Read error: 113 (No route to host)]
jlouis has quit [Read error: 110 (Connection timed out)]
__suri_ has quit []
leo037 has joined #ocaml
brooksbp has quit []
filp has joined #ocaml
brooksbp has joined #ocaml
det has quit [Read error: 110 (Connection timed out)]
seafood_ has joined #ocaml
seafood_ has quit []
jdh30 has joined #ocaml
ikaros has joined #ocaml
leo037 has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
ertai has joined #ocaml
joshcryer has quit [Nick collision from services.]
joshcryer has joined #ocaml
Tov_enst has joined #ocaml
brooksbp has quit []
jlouis_ has quit [Read error: 110 (Connection timed out)]
mrsolo_ has joined #ocaml
brooksbp has joined #ocaml
Tetsuo has joined #ocaml
ramkrsna has quit ["Leaving"]
ertai has quit [Read error: 110 (Connection timed out)]
mrsolo__ has quit [Read error: 110 (Connection timed out)]
brooksbp has quit []
brooksbp has joined #ocaml
brooksbp has quit [Remote closed the connection]
Abo-Marwan60 has joined #ocaml
det has joined #ocaml
jdh30 has quit [Read error: 110 (Connection timed out)]
jdh30 has joined #ocaml
Abo-Marwan60 has quit [Remote closed the connection]
Yoric[DT] has joined #ocaml
flux- has joined #ocaml
flux has quit [Read error: 54 (Connection reset by peer)]
Tetsuo has quit [Remote closed the connection]
mrsolo__ has joined #ocaml
b00t has joined #ocaml
ertai has joined #ocaml
mrsolo_ has quit [Read error: 113 (No route to host)]
brooksbp has joined #ocaml
smimou has joined #ocaml
brooksbp has quit [Client Quit]
screwt8 has joined #ocaml
flux- is now known as flux
Abo-Marwan60 has joined #ocaml
hkBst has joined #ocaml
Snark has quit ["Quitte"]
olleolleolle has joined #ocaml
buluca has joined #ocaml
jlouis has quit [kubrick.freenode.net irc.freenode.net]
filp has quit [kubrick.freenode.net irc.freenode.net]
mattam has quit [kubrick.freenode.net irc.freenode.net]
eck has quit [kubrick.freenode.net irc.freenode.net]
richardw has quit [kubrick.freenode.net irc.freenode.net]
cmeme has quit [kubrick.freenode.net irc.freenode.net]
asmanur has quit [kubrick.freenode.net irc.freenode.net]
bebui has quit [kubrick.freenode.net irc.freenode.net]
buluca has quit [kubrick.freenode.net irc.freenode.net]
ikaros has quit [kubrick.freenode.net irc.freenode.net]
pattern has quit [kubrick.freenode.net irc.freenode.net]
jeremiah has quit [kubrick.freenode.net irc.freenode.net]
jdavis_ has quit [kubrick.freenode.net irc.freenode.net]
rwmjones has quit [kubrick.freenode.net irc.freenode.net]
kmeyer has quit [kubrick.freenode.net irc.freenode.net]
zmdkrbou has quit [kubrick.freenode.net irc.freenode.net]
buluca has joined #ocaml
ikaros has joined #ocaml
pattern has joined #ocaml
jeremiah has joined #ocaml
rwmjones has joined #ocaml
jdavis_ has joined #ocaml
kmeyer has joined #ocaml
zmdkrbou has joined #ocaml
b00t has quit [Remote closed the connection]
mattam has joined #ocaml
richardw has joined #ocaml
bebui has joined #ocaml
asmanur has joined #ocaml
cmeme has joined #ocaml
eck has joined #ocaml
jlouis has joined #ocaml
filp has joined #ocaml
screwt8 has quit [Remote closed the connection]
Abo-Marwan60 has quit [Remote closed the connection]
screwt8 has joined #ocaml
rwmjones has quit [kubrick.freenode.net irc.freenode.net]
pattern has quit [kubrick.freenode.net irc.freenode.net]
jdavis_ has quit [kubrick.freenode.net irc.freenode.net]
kmeyer has quit [kubrick.freenode.net irc.freenode.net]
ikaros has quit [kubrick.freenode.net irc.freenode.net]
zmdkrbou has quit [kubrick.freenode.net irc.freenode.net]
buluca has quit [kubrick.freenode.net irc.freenode.net]
jeremiah has quit [kubrick.freenode.net irc.freenode.net]
buluca has joined #ocaml
ikaros has joined #ocaml
pattern has joined #ocaml
jeremiah has joined #ocaml
rwmjones has joined #ocaml
jdavis_ has joined #ocaml
kmeyer has joined #ocaml
zmdkrbou has joined #ocaml
Snark has joined #ocaml
screwt8 has quit [Remote closed the connection]
hkBst_ has joined #ocaml
<det>
What is the syntax for functional record update?
<zmdkrbou>
{ r with field = something }
<Smerdyakov>
{ go = check ; the + manual } ;-)
<tsuyoshi>
strangely enough, I can't remember ever seeing anyone use it
<det>
Thanks.
<det>
I can't find it in the manual.
<zmdkrbou>
tsuyoshi: this syntax ?
<Smerdyakov>
tsuyoshi, I use it plenty.
<zmdkrbou>
so am i
<tsuyoshi>
zmdkrbou: yeah.. like I knew about it, but I've only ever seen it in tutorials
<zmdkrbou>
if you use records you use this (or you don't use functionnal style :p)
<tsuyoshi>
well I've always just created entirely new records myself..
<tsuyoshi>
but in other people's code I've only seen them mutate the records
* vincenz
has used it in the past too
<tsuyoshi>
maybe I haven't seen enough code yet
<Smerdyakov>
Or maybe you only read bad code. :P
<vincenz>
Said less trollishly: maybe only code in a domain that does not require functional records
screwt8 has joined #ocaml
<tsuyoshi>
in what kind of situation do you find functional records useful?
<zmdkrbou>
when you're using records and using ocaml
<Yoric[DT]>
:)
<vincenz>
zmdkrbou: I raise that statement
<vincenz>
"whenever you're using records and using ocaml or haskell"
<zmdkrbou>
because you want to use functional style, and records are great as "labelled" tuples
authentic has quit [No route to host]
<det>
I am guessing functional record update would be a lot more useful in a compiler like MLton. Since it can flatten the record some times, where it is always a copy in Ocaml.
<zmdkrbou>
det: well that's a performance issue but functional use of the records has obvious style benefits
mrsolo_ has joined #ocaml
<tsuyoshi>
well I mean.. usually when I am using records I will write a function that takes one type of record as an argument and returns an entirely different type of record
<tsuyoshi>
I've never written anything with mutable records
<zmdkrbou>
you never, say, use a record as an accumulator in a fold ?
<tsuyoshi>
no, I've never done that
<tsuyoshi>
huh.. I think if I was doing something like then I would mutate the record
<zmdkrbou>
rhoooo, that's not functional :)
<zmdkrbou>
applicative, i mean
<det>
If you are mutating the record, you aren't using fold, you ate using iter (a special form of fold).
<tsuyoshi>
well, yeah
ikaros has quit [Remote closed the connection]
ikaros has joined #ocaml
mrsolo__ has quit [Read error: 113 (No route to host)]
olleolleolle has left #ocaml []
Snark has quit [Remote closed the connection]
hkBst has quit [Nick collision from services.]
hkBst_ is now known as hkBst
ttamttam has joined #ocaml
Snark has joined #ocaml
gim_ is now known as gim
__suri has joined #ocaml
Tetsuo has joined #ocaml
mrsolo__ has joined #ocaml
mrsolo_ has quit [Read error: 110 (Connection timed out)]
ita has joined #ocaml
rwmjones has quit ["Closed connection"]
rwmjones has joined #ocaml
pango has quit [Remote closed the connection]
Yoric[DT] has quit [Read error: 113 (No route to host)]
pango has joined #ocaml
ita has quit [Read error: 110 (Connection timed out)]
ttamttam has left #ocaml []
JohnnyL has joined #ocaml
marmottine has joined #ocaml
<guyzmo>
/j #ocamlfr
Yoric[DT] has joined #ocaml
CRathman has joined #ocaml
<JohnnyL>
haha!
<guyzmo>
it seems there *used* to be a french ocaml channel :)
<JohnnyL>
guyzmo, do you have a beard?
<JohnnyL>
guyzmo, snagged! haha
<guyzmo>
JohnnyL - lol, I shaved it last monday, had a job interview :P
<JohnnyL>
guyzmo, :(
<guyzmo>
but I have long hair
<guyzmo>
:p
<JohnnyL>
and your french!
* JohnnyL
loves Merovingian from The Matrix. I wanna be more like him.
<guyzmo>
lol
<guyzmo>
you can get the language, at least
<guyzmo>
putain de bordel de merde de nom d'une chiotte de mes deux de couille de connerie de pute de sa race !
<JohnnyL>
hahahahahah!!!
<JohnnyL>
i was just thinking about that!
<JohnnyL>
I just love the way it rolls off the tongue. :)
<guyzmo>
I often say things like that
<guyzmo>
very often those days as I'm learning ocaml :)
<guyzmo>
just to say "why am I so damn stupid ?"
<JohnnyL>
there are not many French people on the internet.
<guyzmo>
well, I find there is too much
<guyzmo>
already too much, I mean
<guyzmo>
:]
mrsolo_ has joined #ocaml
<zmdkrbou>
JohnnyL: depends where ... here, there's a lot
<JohnnyL>
Cause effect... effect cause... but this is all rather academic...
<JohnnyL>
how about Beloque frmo Raiders of the Lost Ark? <snickers>
svenl has quit [Nick collision from services.]
svenl has joined #ocaml
svenl_ has joined #ocaml
<guyzmo>
JohnnyL - you see, in 3 minutes, 3 frenchs appeared :)
<JohnnyL>
guyzmo, to the stations!
<guyzmo>
but I'm sure most of them are related to paris VI, XI or the CNRS, one way or the other :P
<Yoric[DT]>
Not to mention already present French lurkers.
<jonafan>
je parle apil francais
<JohnnyL>
the french know good languages! :)
svenl has quit []
ertai has quit [Read error: 110 (Connection timed out)]
mrsolo has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
mrsolo__ has quit [Connection timed out]
rwmjones has quit ["Closed connection"]
rwmjones has joined #ocaml
mrsolo_ has quit [Connection timed out]
robyonrails has joined #ocaml
<robyonrails>
hi guys, who have read "Practical OCaml" ???
<Yoric[DT]>
IIRC nobody.
<Yoric[DT]>
(including the author)
filp has quit ["Bye"]
<guyzmo>
as a matter of fact I did :]
<guyzmo>
though I did not finish it
<JohnnyL>
imagines roby crucified on two sets of steel ibeam rails.
<robyonrails>
what's your opinion, guyzmo? I've read terrible reviews :D
<guyzmo>
robyonrails - well, it's not worst than many tutorials I've read online, and it has codes in it
<guyzmo>
but my opinion is that I'm still damn bad in thinking correctly in ocaml though I begun learning it 2 monthes ago
<robyonrails>
I must review it, do you have any advice for me (ex: you should read something better before) ?
<guyzmo>
so that book was not really helpful in my case, and I still haven't found the holy grail that will make me smarter to really think functionaly
<guyzmo>
you already know ocaml or you're learning it as well ?
<robyonrails>
the latter
smimou has quit ["bli"]
<robyonrails>
I noticed it's a bit confusing in explaining concepts .. :(
<guyzmo>
well, imho it's more like some kind of k&r of ocaml : it tells you about the features, but it does not really help you understand them
<robyonrails>
so I can play on learning syntax
<guyzmo>
I don't think it's worth spending money for it, it's not better than the online ocaml tutorial
<robyonrails>
oki
<robyonrails>
thank you, I return to reading (I'd like to finish early :D)
<guyzmo>
the only plus is that it gives you code examples, but I'm not sure learning ocaml through examples is the right approach
<guyzmo>
but on that matter, you should ask people that are "fluent" in ocaml to make your opinion, I'm still far from it
<guyzmo>
I'm still a damn noob :/
<robyonrails>
:)
<guyzmo>
and I have a compiler to write in ocaml as a project for university and still being dumb in ocaml is driving me crazy
<Yoric[DT]>
Well, I've met a few fluent people who have read that book and consider it awful.
<Yoric[DT]>
By just about every account.
<guyzmo>
Yoric[DT] - what would you advice to get fluent in ocaml and in functional programming ?
<Yoric[DT]>
I've heard that "OCaml for scientists" is quite good but I haven't managed to grab it yet.
<guyzmo>
to get further than that imperative way of thinking
<JohnnyL>
how does imperative processing of functional programming generally evaluate under ocaml's source?
<Yoric[DT]>
Someday, I'll try and write an OCaml tutorial.
<Yoric[DT]>
Otherwise, the book included with Debian distros was rather good, iirc.
<Yoric[DT]>
"Developing applications with Objective Caml"
<Yoric[DT]>
A bit old now, but free.
<guyzmo>
hm, just installed it
<guyzmo>
I'll begin reading it right now :)
<Yoric[DT]>
:)
<Yoric[DT]>
Enjoy :)
<Yoric[DT]>
If you have any question, feel free to ask.
<guyzmo>
well, I understand the concepts, I just get lost when I try to write code or when I try to get into someone else's code
seafood_ has joined #ocaml
<guyzmo>
I think what I'd need now is to get good exercises to progressively feel the language's features and not only know about them
<Yoric[DT]>
Sounds like a good plan.
buluca has joined #ocaml
seafood_ has quit []
ikaros_ has joined #ocaml
ikaros has quit [Read error: 104 (Connection reset by peer)]