smimou changed the topic of #ocaml to: OCaml 3.08.3 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/
monochrom has quit ["good morning, sweet dream"]
vezenchio has quit ["Ayn Rand encapsulates the rage that every teenager feels on finding that his first paycheque has had taxes taken out of it"]
gim_ has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]
gim_ has quit [Read error: 110 (Connection timed out)]
gim has joined #ocaml
joeytwiddle has joined #ocaml
ulfdoz has joined #ocaml
ulfdoz_ has quit [Read error: 145 (Connection timed out)]
gim_ has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]
Herrchen_ has joined #ocaml
batdog is now known as batdog|gone
Herrchen has quit [Read error: 110 (Connection timed out)]
mlh_ has quit [Client Quit]
mlh_ has joined #ocaml
batdog|gone is now known as batdog
Submarine has joined #ocaml
__DL__ has joined #ocaml
batdog is now known as batdog|gone
Snark has joined #ocaml
bk_ has quit [""(quit)""]
haakonn has quit [Read error: 110 (Connection timed out)]
batdog|gone is now known as batdog
pango has quit [Remote closed the connection]
batdog is now known as batdog|gone
vodka-goo has joined #ocaml
mlh_ has quit [Client Quit]
batdog|gone is now known as batdog
raboof has joined #ocaml
<raboof> can i patternmatch over a string? like `match name with firstchar :: rest -> ...'?
<mflux_> I don't think so
<mflux_> you would need to first split the string into a character list
<raboof> ok
<raboof> that might explain why i couldn't get that to work :)
<raboof> is there a standard function for converting string to char list?
<vodka-goo> there is a split somewhere
<vodka-goo> streams can be better for what you need
<vodka-goo> can avoid creating a (possibly large) list
<raboof> hm the strings won't be big (max 20 chars or so)
<raboof> the goal is to `escape' the string (but in an application-specific way, so i can't use String.escape)
<raboof> non-destructively
<vodka-goo> Str.split
<vodka-goo> maybe it's overkill
<vodka-goo> Str.split (Str.regexp "") "bla" -> ["b";"l";"a"]
<raboof> hmm where are the docs for Str?
<raboof> how do i load Str? :) (i get 'Reference to undefined global `Str'' ;))
<mflux_> #load "str.cma";;
<mflux_> when used interactively, ocamlc str.cma yourstuffhere.. otherwise
<raboof> aha ok, thanks
<raboof> weird how string manipulation is a pain in almost any language
<gim_> vodka-goo: it's a bit overkill to use regexps just to do that, isn't it ? :)
<vodka-goo> gim_: I agree, and said that
<gim_> k, you're already aware of it...
<vodka-goo> moreover, it splits to chars
<ulfdoz> <- alive
<raboof> gim_: how would you recommend doing it?
<gim_> probably I would forget this time about pretty functionnal fold, and use a for i = 0 to String.length s - 1 do ... s.[i] ... done
<gim_> or search for this function in extlib
<raboof> that hurts because when a character is escaped the string becomes longer
<mflux_> simply split the string into list of strings, map them with a function and then String.concat them?
<mflux_> the only work is the first function
<mflux_> also it won't be very fast..
<mflux_> I'd guess
<raboof> that was basically vodka-goo's suggestion, yes, right?
<mflux_> yes, but not spelled out, apparently there were still other attempts ;)
<gim_> (fold on strings is ExtString.String.fold_left in extlib)
<gim_> then you might build a automata by hand which appends it's output to the state * string parameter of the fold
Saulzar has joined #ocaml
<ulfdoz> Wow, traffic? here? :)
mauke has quit [Remote closed the connection]
mauke has joined #ocaml
<raboof> ;)
* Snark wonders about ocaml-gettext
<Saulzar> I'm getting some real wierdness with a function which seems to do different things some of the time - it has no side effects (except the debug statements) which is confusing the crap out of me. Sometimes the string concatenator will overwrite the text eg. "abcd" ^ "123" will come out "123d" instead of "abcd123"
<Saulzar> I've posted the code here with the sample output - I'm really not quite sure how to debug this, the arguments to the function print out fine and I can't reproduce it anywhere else http://rafb.net/paste/results/mVWQGZ25.html
<vodka-goo> Saulzar: what do you use the result for ?
* Snark goes reading the code
<Saulzar> It returns a pair string * float (x, y) which means it will use it after y seconds ... (send it across network)
<Saulzar> I noticed it when I was printing debug somewhere else in the program (matching the tuple then printing it) much later on..
<Saulzar> When it did the same thing
gim_ has quit []
<Saulzar> If I swap the order of the string concatenation around it prints out fine - and if I print the arguments out individually they seem correct
<Saulzar> Er - the result sorry
<vodka-goo> Saulzar: do you chop \n off your command before giving it to your function ?
<vodka-goo> maybe sometimes there's \r and you don't remove it
<vodka-goo> well it doesn't explain the end of your weird output..
<vodka-goo> I've got another possible hint, not sure there's a link, but it's a tricky thing:
<vodka-goo> # let f () = "bla" ;;
<vodka-goo> val f : unit -> string = <fun>
<vodka-goo> # (f ()).[0] <- 'i' ;;
<vodka-goo> - : unit = ()
<vodka-goo> # f () ;;
<vodka-goo> - : string = "ila"
<vodka-goo> the string constants are defined once for all
<vodka-goo> strings are not purely functional
<Saulzar> Wierd...
<Saulzar> Hmm.
<Saulzar> I see - so you're assinging the "constant", heh
<Saulzar> Hmm- it comes from the result of input_line .. didn't think it had a \n, maybe that's why
<Saulzar> Oh, I see - it is sent a \r\n for windows machines
<Saulzar> That seems to trigger it, I'll be damned - I thought it was more suspicious than just the printout. But I guess that makes sense
<Saulzar> Thanks a lot
<vodka-goo> Saulzar: so it was \r ? but why doesn't \r applies when you print "2" ^ reponse on the weird output ?
<Saulzar> Hmm
<Saulzar> Ah - because it's the last thing on the line
<Saulzar> So the \r does nothing
<Saulzar> But on the earlier one it goes "asdfasdfadsf \r 346346346346" so it prints asdfasdfasdf then rewinds and prints 346346346 over the top of it
<Saulzar> But the later one is "2 response \r"
<Saulzar> I wasn't even aware that \r did anything on unix :)
<sieni> Well...
<sieni> If your program puts the terminal in raw mode, then you probably want to send \e
<sieni> oops
<sieni> \r\n to the terminal
<vodka-goo> ok I didn't notice \r was at end of line, thought something was concatenated after
<Saulzar> Probably a good idea to be portable - but definately not a good idea to put \r in the middle of strings ;)
<Saulzar> Heh
<Saulzar> Attacking a red with mono medusa???
<Saulzar> Camel (#7905)'s Red Dragons attacked mamrd (#2042)'s Medusas.
<Saulzar> Camel (#7905)'s Red Dragons slew mamrd (#2042)'s 5310 Medusas units.
<Saulzar> Whoops
<Saulzar> Sorry - bad channel.
<Saulzar> Thanks for the assistance
Saulzar has left #ocaml []
mrpingoo has joined #ocaml
mrpingoo has quit [Read error: 54 (Connection reset by peer)]
Submarine has quit ["Leaving"]
batdog is now known as batdog|gone
batdog|gone is now known as batdog
Saulzar has joined #ocaml
TaXules is now known as MajorTaXules
Smerdyakov has joined #ocaml
gim has joined #ocaml
Smerdyakov has quit [Read error: 145 (Connection timed out)]
Frederick has joined #ocaml
<Frederick> does anyone here happen to know how to use contain function in ml?
<vodka-goo> contain ?
<vodka-goo> That Char module is no standard one
<vodka-goo> but it would be something like Char.contains "bla" 'a'
<Frederick> dammit I need to do my homework but mml sucks a lot
<Frederick> Syntax error.
<Frederick> how long would it take to make a simple parser to remove , from a file in ocaml?
<Saulzar> Not long, you could do it in 1 small function if you use the string functions in the standard lib
vezenchio has joined #ocaml
<Frederick> im reading the docs can you help me a bit?
monochrom has joined #ocaml
<Saulzar> Maybe if you use Str.replace from the Str module then you could have something working fast (not nesescarily good, nor efficient though)
<Saulzar> (I'm off to sleep)
__DL__ has quit [Remote closed the connection]
pattern_ has quit ["..."]
pattern_ has joined #ocaml
mfurr has joined #ocaml
mrsolo has joined #ocaml
vodka-goo is now known as estelle
Submarine has joined #ocaml
pango has joined #ocaml
estelle has quit []
<Snark> good night
Snark has left #ocaml []
psnively has joined #ocaml
<psnively> Testing, 1, 2, 3...
psnively has left #ocaml []
mrvn_ has joined #ocaml
<ulfdoz> Gute Nacht
<Frederick> what is worng here now -> http://rafb.net/paste/results/wpvMmb92.html ?
mfurr has quit ["Client exiting"]
mrvn has quit [Read error: 110 (Connection timed out)]
Submarine has quit ["Leaving"]
<pango> Frederick: ; after letra line...
<Frederick> ?
<pango> the while syntax (while cond do ... done)
<pango> letra = !c is probably not what you expect (it's a test)
<Frederick> ive fixed the Then now i have then
<pango> no isLower function in standard Char module
<Frederick> ?
<Frederick> im using mosml
<pango> and channel is #ocaml
<Frederick> pango mosml has no channel
<Frederick> not docs
<Frederick> nor docs
<pango> you ask what's wrong with code without any warning about the language used
<pango> blame yourself
* Frederick blames him self
<Frederick> I could tryto make it in ocaml but im affraid it will be even harder
<pango> I don't know mosml, but the comment about letra = !c is still correct
<pango> (probably)
<Frederick> why?
<pango> in this context, = is the comparison operator
<pango> (physical or by value I don't know, it depends on mosml)
<pango> letra is immutable, and its value is the empty string
batdog is now known as batdog|gone
<Frederick> it doesnt works =/
<pango> # cat3 "/etc/fstab" ;;
<pango> etcfstabstaticfilesysteminformationfilesystemmountpointtypeoptionsdumppassprocprocprocdefaultsdevhdareiserfsnotaildevhdahomereiserfsdefaultsdevhdawinxpvfatdefaultsrwuidgiddevhdanoneswapswdevcdrommediacdromisorousernoautodevfdmediafloppyautorwusernoautodevsdamediavoyageurvfatrwusernoauto- : unit = ()
<monochrom> eh, it skips all the spaces?
<Frederick> well im using winows and mosml maybe this is the problem
<pango> it only keeps lowercase letterzs
<pango> that's ocaml code
<monochrom> hahahahahaha
<Frederick> :(
<monochrom> When will all this end?
<Frederick> monochrom what?
<Frederick> Im bursting my as for 6 hours here trying to make this crap work
<monochrom> Your ordeal of getting your homework done by irc.
<monochrom> How many more assignments? When will the class end?
<Frederick> im not asking you to do my homework
<Frederick> this is the only assignment class end on next week.
<Frederick> but as far as Ican see the point of these functional languages is to be obscure
<Frederick> if I wasnt doing it in c I would have tons of examples samples and stuff
<pango> Frederick: your code isn't exactly an example of functionnal programming ;)
<Frederick> pango I had 3 classes of 1 hour each about functional programming dont expect poetry on these lines
<pango> Frederick: but functionnal paradigm is nowhere to be found in your code
<pango> Frederick: it's just C code with different keywords
<pango> I must admit I/O is not the best topic for functional programming
<Frederick> pango Im a c programmer
<pango> Frederick: it shows
<Frederick> my teacher asks me to do this in mosml
<pango> Frederick: tell me something I didn't guess
<Frederick> I wont be able to change my mind in 7 days I have to do the work cause I have tons of other assignments, so Im using a screwdriver as a hammer but who cares as long as the job is done
<pango> Frederick: the question is, what's the point of this assignment ? Get a working program, or teach you new paradigms
<monochrom> I had my turn of being a newbie too. I had to pick up SML in the last century; no tutorial on the www back then. I just picked up a book and in two weeks I was doing well. Also self-study, no teacher, no irc help. Been there, done that, succeeded. That is why I completely disbelieve both your complaints and your competence.
<Frederick> pango Get a working program of course
<pango> Frederick: well, in my book, of course teachers are there to teach you things
<Frederick> monochrom you had 2x more time + no assignment you could have taken a month to do reach the point im
<Frederick> pango are you in the university?
<pango> Frederick: no
<monochrom> Excuses excuses.
<Frederick> pango lemme tell you a secret, teacher at uni dont know what a heck they are asking
<Frederick> sice the girl who gives the class gave us wrong sample codes
<Frederick> and she also doesnt know ml
<Frederick> this is university life welcome to the jungle
<pango> Frederick: nothing wrong with being smarter than the teacher
<monochrom> speak for your university only.
<Frederick> monochrom are you on the university?
<monochrom> I am not in your university.
<Frederick> monochrom I didnt asked if you are on my university Ive asked if you are on the university
<monochrom> You can badmouth your class all you want, but just don't generalize.
<monochrom> I'm *in* *a* university.
<Frederick> unfortunatelly I wasnt blessed with a good teacher
<Frederick> monochrom what ever im brazillian english inst my mother language
<pango> it's not mine either
<Frederick> mas vocês são burros demais pra falar outras linguas.
<pango> pas mieux ici
<Frederick> monochrom te tu parle france?
<monochrom> not mine either, I'm Chinese.
<pango> either way, I don't think you should rush to get code working, if you fail to learn functionnal paradigm, it's much more important
<Frederick> pango do you belive I can learn the paradigm with 1 assigment I have 5 days to do? with like other 6 classes im taking? it like learn c cause you wrote hello world
<Frederick> pango once I have the program working I can use time to review correct and improve it
<pango> Frederick: I think it's the wrong way, but I'm not you
<monochrom> You started asking yesterday. You said it's due next Friday. I don't believe you were given less than one week.
<Frederick> pango so the right way is to get a book, read it, do all the exercises and get it done in like 3~4 weeks right?
<pango> Frederick: functional programming is only a few important concepts. Once you got them, you can do many exercices to understand their consequences, but is not as important
<pango> Frederick: But getting radically new concepts without a good teacher is probably *the* problem :/
<monochrom> I didn't have a teacher.
<pango> I didn't either, but I had lot of free time by then
<monochrom> I had classes too when I did it.
<pango> I used lisp and logo way before I took any programming classes
<pango> I probably didn't get all the important ideas at the time, however. Just trying stuff
<monochrom> while true do { read another paragraph; try out the code show; try out mutated code I invent } was all I did.
<monochrom> s/show/shown/
<pango> something like that too
<monochrom> the _ml's all have interactive environments, type in a command and immediately see result, you can experiment with no overhead, all those nice things people say about scripting languages like python applies.
<Frederick> monochrom all you are saying me is that if I want to learn sml Iwill need more than what im doing but you are requesting me the same as read all the Stroustrop book in order to use printf("");
<monochrom> You can't even say that about C. I am surprised you use that as a basis for comparison and actually speak in favour of it. Don't you think that having to wrap your experimental code into int main() {...} properly was a hurdle?
<Frederick> monochrom no since I had tons of samples
<monochrom> You are so keen on sample code.
<monochrom> As far as I can tell, you are saying that a C class poses no problem because you can finish your homework by copying from samples.
<Frederick> monochrom I learn stuff by examples
<Frederick> monochrom no since I can learn seeing samples.
<monochrom> I learn by examples too. I improvise my own examples.
* Frederick I wish I invent a dispositive to stab ppl on the face over internet
<monochrom> For example "mapstring - how to use it?" just how many dozen examples do you need before you can see it? This is not rocket science.
<pango> Frederick: in your case it's like learning maths from examples, using your knowledge of philosophy
<pango> Frederick: you can write plenty of things that look like maths that way... but that are simply worthless
<monochrom> You see me as annoying. Do you realize that you come across as a pest in the first place?
skylan has joined #ocaml
<pango> Frederick: learning from examples work when you understand 90% of them, and try to learn the other 10%
<Frederick> pango you first sums where just copies of what your teacher wrote, cause you coulnt make the code your own, caus you didnt knw ohow it worked like the prime numbers
<pango> Frederick: well, if you wrote code from teacher's example, she doesn't know functional programming :)
<Frederick> pango she doesnt
<Frederick> wanna see her class material?
<pango> why not
<pango> is it online ?
<Frederick> sure
<Frederick> could you open it/
<pango> I'm reading the first one, seems to work
<pango> trying to guess the portuguese parts
<pango> first page is very generic syntax, nothing really specific to functional languages there
<monochrom> It is superficial for sure.
<Frederick> this is all the class I had, btw she didnt explained the material since you can read as she said
<pango> the come types and type inference... then recursion...
<pango> then exercices involving I/Os... mmmh
<pango> that's a large gap
<Frederick> ?
<monochrom> Ah I said superficial because I only knew #1
<monochrom> #2 invites you to try out hd(explode "south") etc. to see what they do.
<monochrom> My impression is it already has examples. Not examples that you can copy and finish homework, of course. But examples. Examples that shows you how to do simple things and what the result is. Examples upon which you can keep adding things and get your own larger examples.
<pango> teaching that some languages are functional because they have sin() and cos() ... Did I miss something ? :)
<monochrom> "what is functional" that has no consensus. furthermore I hold a minority opinion on that.
shrimpx_ is now known as shrimpx
<pango> there's some margin for improvement
<monochrom> For example algebraic data types and HM polymorphism (type 'a blah = Boo | Happy of 'a) I don't consider part of functional programming; I consider it a feature that any programming could adopt or not, and it happens that the functional people has and the imperative people hasn't.
<pango> sure
<monochrom> There was also a time in the last century when people considered garbage collection to be exclusive to functional programming, but you know time has changed.
<pango> right
<pango> GC is more a consequence than a prerequise
<monochrom> if a language streamlines these - function application, anonymous functions, higher-order functions and currying - I'm happy enough to consider it functional.
<pango> same here, and I see little of that in the above two pages of class material
<monochrom> (likewise if one writes a program in terms of mostly those, I'm happy to call it functional programming)
<monochrom> there is the usage of a specific higher-order function, namely map :)
<pango> and some examples of recursive functions... that's a start ;)
Frederick has quit ["Easy as 3.14159265358979323846..."]
johs has quit [Read error: 110 (Connection timed out)]
monochrom has quit ["good morning, sweet dream"]