<sgillespie>
I'm trying to figure out how to do a destructive insert on a list
<sgillespie>
say i have a list []
<sgillespie>
i want something like
<sgillespie>
5 :: a -- and assign the result to a
<Smerdyakov>
Lists are immutable, as are variables.
<sgillespie>
is there a such thing as a mutable-list?
<Smerdyakov>
You need to use them in concert with mutable types to achieve what you say... BUT you probably just need to reconceptualize your algorithm functionally/recursively.
<sgillespie>
i was thinking that lists were mutable because List defines an append method
<Smerdyakov>
No, that's a function, not a method.
<Smerdyakov>
And 'append' has no association with mutation in the FP world.
<sgillespie>
ah...See I'm thinking in java
<sgillespie>
dangerous
<Smerdyakov>
The manual should have all the info you need on refs, arrays, and mutable fields, which are the ingredients OCaml provides for building mutable structures.
<Smerdyakov>
But, again, it's usually a failing on the programmer's part when he uses mutability.
<psnively>
sgillespie: Welcome to the red pill. :-D
<sgillespie>
okay, that brings me to more questions
<sgillespie>
I agree, that most applications don't require mutability
<sgillespie>
I'm going for a symbol table...I can't think of a clean, "functional" way to do that
<psnively>
Sounds like Map.
<Smerdyakov>
Why not an applicative dictionary?
<sgillespie>
Well, I was going to use a list of hashtables
<Smerdyakov>
See, this is a great example. You couldn't have given a better example if someone had fed you the best thing to ask to illustrate how great functional data structures are.
<psnively>
Heh.
<Smerdyakov>
You don't need anything more complicated than a Map for this, and here's why:
<sgillespie>
okay
<Smerdyakov>
You build a separate symbol table for every scope, CONTAINING EVERY SYMBOL. No need to separate it out linearly as you have.
<Smerdyakov>
You naturally get sharing with existing structures, and there's no mutation to modify an "old copy" that someone else still needs.
<Smerdyakov>
Obviously nicer for programming convenience and reliability of the result.
<Smerdyakov>
Time overhead vs. hash tables is O(log V), where V is the maximum number of variables in any scope; and space overhead is O(N log V), where N is the total number of variables in an input.
<tsuyoshi>
list of hash tables? why not just a single hash table?
<Smerdyakov>
tsuyoshi, to keep multiple symbol tables for different scopes available at once.
<Smerdyakov>
tsuyoshi, or maybe it's just easier tear-down on leaving a scope.
yodafinger has joined #ocaml
<sgillespie>
both...
<psnively>
Map is the Right Thing.
<Smerdyakov>
Yup. The Map-based solution has no tear-down. You just resume using the old table.
<sgillespie>
map is basically an ordered hash table?
<psnively>
Apart from not being imperative.
<Smerdyakov>
Don't use "hash table" when you really mean "dictionary" or a synonym. Popular scripting languages have co-opted "hash" to denote an ADT, but that's no good.
<sgillespie>
thats a good point
<sgillespie>
i assumed it was implemented as a hashmap, I should really stop doing that
<Smerdyakov>
Yup. It definitely isn't implemented that way.
<psnively>
Yep. For the curious, Map is a red-black tree on an Ordered type.
<sgillespie>
okay...i'm going to have fun with this...I appreciate the advice
<psnively>
Anytime. As I said, welcome to the Red Pill. Look on the bright side: most people have to live through Lisp before getting this far...
<sgillespie>
i started fp with lisp
<psnively>
All kidding aside, it actually is still a leg up. And if you get Java 5 generics, then parametric polymorphism won't be a total mystery either.
<psnively>
(It's just a lot cleaner in ML than in Java 5.)
<sgillespie>
maybe someday my workplace will upgrade to java5 and i can use the new features (i would never use java at home :( )
<psnively>
Well, if you need to run on the JVM but don't want to use Java, I recommend Scala.
<psnively>
But if you don't need to run on the JVM, I recommend OCaml. :-)
<psnively>
And on that note, I have to dash (date with my wife). :-D
<psnively>
See you around!
psnively has quit []
jsnx has joined #ocaml
<jsnx>
is there any way to compile win32 binaries on linux?
<tsuyoshi>
haven't seen a cross compiler, but it should be possible in theory
<sgillespie>
wine?
<jsnx>
sgillespie: yeah, the haskell people said the same thing...
<Payo305>
i already know ocaml ......well basics plsu some network stuff
<seafoodX>
It's remarkable how people can say things like "only C and C++ have a future". I mean, what is that based on?
<seafoodX>
Even if a programming language is only used in a niche market, it's still useful and may well "have a future"
<Payo305>
well
<Payo305>
most people use C becasue its the fastest
<tsuyoshi>
it actually seems to me like most people have already abandoned c/c++ for java
<Payo305>
thats why i say optimize the ocaml compiler more GRRRR
<tsuyoshi>
it's hard for me to worry too much about ocaml being slow when java and ruby are so popular
<seafoodX>
OCaml isn't slow anyway.
<Payo305>
i dont think ruby is popular in the same way C is
<Payo305>
i know its not slow
<Payo305>
its very fast
<Payo305>
but if it neck to neck with C it would have more bragging rights :P
<seafoodX>
You can always write something in C that is faster than an equivalent program in OCaml since C is so close to assembly.
<seafoodX>
There is always an abstraction penalty to be paid.
<tsuyoshi>
I don't know about always
<Payo305>
they dont really focus on optimization
<seafoodX>
Well, if you're prepared to put the time in.
<seafoodX>
Payo305: That's not really true. The optimisation in OCaml is just fine.
<Payo305>
i know
<Payo305>
but its not a focus
<Payo305>
like per say GCC is
<Payo305>
they focus hard on it
<seafoodX>
Hmm, you might have a point there.
<Payo305>
gcc didnt use to do all to well
<tsuyoshi>
heh.. but still, msvc is faster than gcc
<Payo305>
i think ocaml was neck and neck with it actually
<Payo305>
it is ?
<tsuyoshi>
yeah
<Payo305>
by howw much ?
<tsuyoshi>
not much
<Payo305>
ah
<Payo305>
well im jus saying if they do compile optimizations once every 5 years it would keep it up pretty good
<Payo305>
but i dont think they have messed with it at all or atleast to much
<Payo305>
im jus saying for it all to be good even if you dont think it needs optimization
<Payo305>
its still good to do it
<Payo305>
why beacause if ocaml was slower then java would you still use it ? prolly
<Payo305>
but your happy it is .........you would be happpier if it was right next to C ;)
yodafinger has joined #ocaml
smimou has joined #ocaml
zarvok has quit ["BitchX-1.1-final -- just do it."]
Submarine has quit ["in Soviet Russia, Céline Dion owns you"]
leo037 has joined #ocaml
kelaouchi has quit [Remote closed the connection]
kelaouchi has joined #ocaml
<rwmjones>
Payo305 is the same troll as Slacker40? before .. don't feed the troll people
love-pingoo has joined #ocaml
<seafoodX>
Can anyone help me with function `input'
<love-pingoo>
do you have a more precise question ?
<seafoodX>
Sorry. I worked it out just as I wrote that.
kelaouchi has quit [Read error: 104 (Connection reset by peer)]
kelaouchi has joined #ocaml
smimou has quit ["bli"]
seafoodX has quit [Read error: 104 (Connection reset by peer)]
seafoodX has joined #ocaml
seafoodX has quit []
Mr_Awesome has quit ["time to impregnate a moth"]
chs_ has quit []
_blackdog has joined #ocaml
_blackdog has left #ocaml []
yminsky has joined #ocaml
yminsky has quit []
love-pingoo has quit ["Leaving"]
tty56_ has joined #ocaml
yminsky has joined #ocaml
G has quit ["FATAL: Module brain not found."]
G has joined #ocaml
tty56 has quit [Read error: 113 (No route to host)]
yminsky has quit []
sgillespie has quit ["leaving"]
yminsky has joined #ocaml
yminsky has quit []
schme has joined #ocaml
schme has quit [Remote closed the connection]
mattam has quit [Read error: 113 (No route to host)]
mattam has joined #ocaml
zarul has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
mattam has joined #ocaml
cjeris has joined #ocaml
__mattam__ has joined #ocaml
bluestorm_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
kelaouch1 has joined #ocaml
kelaouchi has quit [Read error: 104 (Connection reset by peer)]
pango_ has quit [Remote closed the connection]
leo037 has quit ["Leaving"]
pango_ has joined #ocaml
gunark has quit ["Konversation terminated!"]
hcarty has quit [Remote closed the connection]
<Payo305>
rwmjones: i ddint even bring it up
<Payo305>
rwmjones: and once more i work for a insurance company a 40,000 person staff, the number 1 reason they use C is becasue its fast, soo saying speeddoesnt matter is just stupid .........it may not make a difference but in peoples view / what they are going to choose for thier programming language it does plays a big role
Smerdyakov has joined #ocaml
clog has joined #ocaml
schme has quit ["ERC Version 5.1.4 (IRC client for Emacs)"]
psnively_ has joined #ocaml
visage_ has quit [Read error: 110 (Connection timed out)]
psnively has quit [Read error: 110 (Connection timed out)]
psnively_ is now known as psnively
pants1 has quit [Read error: 110 (Connection timed out)]
pants1 has joined #ocaml
oxylin has quit ["Ex-Chat"]
zarul has quit [Nick collision from services.]
psnively has quit [Read error: 104 (Connection reset by peer)]
psnively has joined #ocaml
zarul has joined #ocaml
psnively has quit [Read error: 104 (Connection reset by peer)]
psnively has joined #ocaml
pants1 has quit [Read error: 110 (Connection timed out)]
ygrek has quit []
<flux>
assembler can be the fastest.. if you have the datasheet of the target's platform memorized and can apply the knowledge
<flux>
iow: usually it's not ;)
<flux>
in c the compiler is not able to do high-level optimizations
<flux>
things like aliasing can hinder it
<psnively>
flux: flip side is, no human can actually remember, let alone apply, the various optimizations that are dependent upon particular combinations of instruction/data flow.
<psnively>
Consider, for example, that modern computer games don't use assembly.
<flux>
they might, in inner loops
<flux>
(or inner^3..)
<psnively>
Believe me--they don't. Not anytime in the past decade.
<flux>
but
<flux>
these days, the weight is in the gpu
<tsuyoshi>
wasn't dead or alive 1 written in assembly
<flux>
so not much use for cpu
<flux>
uh
<flux>
assembly
<flux>
(the same thing, I suppose..)
<psnively>
flux: Actually, with most physics and AI still being done on the CPU, there are still plenty of cases where a title can be CPU-bound.
<tsuyoshi>
oh it was released in 96
<psnively>
tsuyoshi: not sure about DOA 1.
<tsuyoshi>
so not in the past decade anyway
<flux>
yeah, but physics is difficult to optimize in assembler, for a human..
<flux>
it seems to me floating point arithmetic in general is
<psnively>
flux: The point is that in the post-Pentium/PowerPC world, humans have no hope of writing optimal assembly language for any sequence of instructions longer than about a dozen instructions.
<flux>
psnively, I think that's a bit exaggarating.. but very close to the truth, nevertheless
<flux>
(spelling?)
<psnively>
flux: Well, OK: some savant might be capable of it. But I know several of the savants in the industry... ;-)
<flux>
I'm not sure any C compile will produce optimal assembler code either
<flux>
the question is, can a human produce more optimal or not..
<psnively>
flux: And the answer is: no.
<psnively>
To give a specific example, there's no assembly language in the Unreal technology.
<flux>
question and answer, simple, I like it ;)
<flux>
yes, but is unreal technology cpu bound?
<psnively>
flux: It certainly can be. Unreal 3 is, on currently-popular CPUs.
<tsuyoshi>
that's the bigger question
<flux>
wow
<psnively>
flux: Actually, I take that back. Unreal tech tends to be memory-latency-bound.
<tsuyoshi>
what is actually cpu-bound these days?
<flux>
I don't play games a lot
<tsuyoshi>
certainly nothing that I've ever written
<flux>
but actually, goba can be
<flux>
if your cpu isn't very fast :)
<flux>
because it tries to maintain 30 fps
<psnively>
tsuyoshi: A good question. There's a fair amount of scientific computing that still is, even today.
Mr_Awesome has quit ["time to impregnate a moth"]
<flux>
(modeemi.fi/~flux/goba - I haven't maintained that for a while.. ;( )
<psnively>
flux: Cool. :-)
<flux>
I don't count non-realtime things to be 'cpu bound'
<flux>
because they are always
<flux>
hitting character 'a' is cpu bound for a tiny fraction of a second
<psnively>
flux: um, hitting "a" consumes 100% of your CPU? I roll d20 to disbelieve.
<flux>
unless you have interrupts disabled :)
<tsuyoshi>
well they have a standard for how long it should take for response to show on the screen before people get irritated
<flux>
psnively, it does. for. a. tiny. fraction. of. a. second ;-)
<flux>
cpu usually consumes 100% of it when it is processing something
<psnively>
flux is right about trying to maintain 30 FPS, however. That imposes some non-trivial (and non-obvious) constraints.
<flux>
otherwise it consumes 0% and it does it while waiting for an interrupt
<flux>
that's isn't exactly true
<flux>
but it's very close to it
<flux>
mobile optimizations can have cpu perform at something less than 100%..
<psnively>
flux:; OK. I guess I don't see such a small time-quantum of 100% CPU consumption as being meaningful.
<flux>
psnively, well, don't worry, it was nit-picking anyways ;-)
pants1 has joined #ocaml
<psnively>
flux: Yeah, it's the angels/head of a pin thing. :-D
<flux>
psnively, are you new here, btw, I don't recall seing seeing much communicate from your nick here?
<flux>
maybe not, actually
<psnively>
flux: Yeah, I haven't hung out on the channel much, nor do I write the list much, I guess. Generally speaking, OCaml Just Works™.
<flux>
lastlog reveals something
<psnively>
flux: I hang on LtU (I'm an editor) a lot.
<flux>
psnively, nice
<psnively>
Thanks. :-)
<flux>
I recently (about perhaps 6 months ago) discovered LtU.. but after that I discovered programming.reddit, and I suppose its larger (but sometimes mistargeted) palette suits me better. I come back to LtU at times, though ;-)
<flux>
sometimes LtU can be a bit.. too theoretical for me
<psnively>
It's very much a community of programming language designers, which is a very strange subset of programming language users.
<flux>
too bad none (??) of the main 'programming/cs blos
<flux>
blogs' provide their information via nntp
<flux>
I very much see the www based discussion systems as inferior to gnus
<tsuyoshi>
add rss support to your newsreader =^)
<psnively>
Hmmm. I suppose an RSS/Atom -> NNTP gateway would be kinda interesting.
<flux>
tss doesn't answer the question of "what comments I haven't seen earlier", does it?
<flux>
rss, even
<flux>
if it does, I wan't to know about it
<tsuyoshi>
oh for comments
<tsuyoshi>
I don't think so
<flux>
yes, definitely, for comments
<flux>
I actually wrote an rss-nntp-gateway for new blog posts
<tsuyoshi>
it is too bad that everything has moved to crappy web interfaces
<psnively>
I don't know about in general, but LtU provides comments via RSS as well, and they definitely track read/unread.
<flux>
the chairman of a certain computer club likes to maintain a blog instead of posting news, so I wrote that to gateway stuff
<vincenz>
for an irc version of ltu, check #oasis
<flux>
psnively, hey, that's something I didn't know
<flux>
psnively, so perhaps a proper rss reader would suit me
<flux>
psnively, now if all the other cs blogs would follow the suit ;)
<mbishop>
what cs blogs? :/
<psnively>
RSS actually works pretty well, IMHO, given a good reader (I use NetNewsWire on Mac OS X).
<flux>
well.. slashdot (related..), programming.reddit, lambda the ultimate
<flux>
gnus supports rss.. I haven't tried it, though ;-)
<flux>
also for freshmeta I wrote a bayeasian classifier.. but I need to add an interface to it to make in manageable
<flux>
perhaps web-based
<flux>
fnuny
<flux>
funny, even (sorry, I'm a bit drunk..)
<flux>
freshmeat.org is free
<flux>
..
<flux>
freshMETA.org I mean't
<flux>
without the '
<flux>
way to kill conversation ;-)
<psnively>
YABC (Yet Another Bayesian Classifier) ;-)
<tsuyoshi>
what is freshmeta
<tsuyoshi>
never heard of it
<tsuyoshi>
my name server claims freshmeta.org doesn't exist
<flux>
true, because I referred to freshmeat.net
<tsuyoshi>
so you meant freshmeat.net?
<flux>
yes.
<tsuyoshi>
ok, that one I've heard of
<tsuyoshi>
although I haven't used it in years
<flux>
if its search wouldn't suck, it would be terrifi
<flux>
as it is now, it's just nice
<flux>
I read it every few days
<psnively>
Google's "site:" operator is your friend.
<flux>
and sometimes interesting projects pop up
<flux>
yeah
<tsuyoshi>
there's a lot of crappy software in it
<psnively>
There's a lot of crappy software.
<flux>
but freshmeat has the potential to so much better
<tsuyoshi>
if they had some better filtering I would probably look at it
<flux>
because it "knows" the information better
<flux>
I use google for my freshmeat needs, mostly.
<psnively>
It would be fun to hook up an HTTP/HTML screen scraper to a proper knowledge representation system, IMHO.
<tsuyoshi>
but I stopped after I got sick of looking at the billionth php interface for doing the stuff I'm perfectly happy to do with the command line
<flux>
it would be nice if freshmeat.net had some intelligent filtering
<flux>
and that's what my fmbayes tried to do :-)
<flux>
but its interface sucks, and it isn't very usable..
<tsuyoshi>
have you released it?
<flux>
no
<flux>
it would need a web interface
<tsuyoshi>
what kind of interface does it have
<flux>
none
<flux>
well, file-based
<flux>
it retrieves the rss feed
<tsuyoshi>
so you run it, and it dumps everything to an html?
<flux>
and classifies posts per what dbacl says
<psnively>
The problem with Bayesian classifiers tends to be that you then need to build a whole query system around your belief net.
<psnively>
There are other approaches to KR that seem more appropriate.
<flux>
and while classifying it outputs the part of the rss to either interesting or not-interesting, and also outputs the result to stdout, which can be viewed from mail cron sends you
<flux>
psnively, well, can you point me to a system as simple to use as dbacl, to apply those?-)
<psnively>
Of course not.
<flux>
that fmbayes (btw, it can be seen with darcs from http://modeemi.fi/~flux/software/fm-bayes) is based on the earlier-mentioned rss-to-nntp-gateway, and is quite simple..
<tsuyoshi>
what is dbacl?
<flux>
dbacl is a generic bayesian classifier
<psnively>
I'll commit a heresy here and claim that classification isn't the hard part.
<flux>
it can be used for filtering spam from mail, among other things
<flux>
I've used it for classifying papers I've scanned
<flux>
I've scanned papers (boring real-life-stuff) and run them though ocr (gocr infact)
<tsuyoshi>
so it works on graphic files? or they were ocred?
<tsuyoshi>
oh
<flux>
and then I created a separate category for each company
<flux>
and taught dbacl for them
<psnively>
Working directly on graphic files WOULD be impressive. ;-)
<tsuyoshi>
could it work on things other than text?
<flux>
and then after scanning a paper it can suggest which company the paper belongs to
<tsuyoshi>
it would be pretty cool if you could do it with pictures or sounds
<flux>
and the cool thing it it even works, and it even works most of the time!
<flux>
too bad my scanner broke..
<flux>
tsuyoshi, I suppose it could use the underlying bayesian algorithm, but first you'd need to separate the data to a list of tokens..
<flux>
perhaps you could extract a token like "mostly-red" or "has-rectangles"
<flux>
psnively, do you have reference to better-suitable classifiers, or is that something a university (or similar..) has taught you?