__DL__ changed the topic of #ocaml to: OCaml 3.09.0 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/
malc_ has quit ["leaving"]
pnou has quit [Read error: 104 (Connection reset by peer)]
TaXules has joined #ocaml
batdog is now known as batdog|gone
TaXules has quit [Read error: 104 (Connection reset by peer)]
TaXules has joined #ocaml
_fab has quit []
pnou has joined #ocaml
TaXules_ has joined #ocaml
TaXules has quit [Read error: 104 (Connection reset by peer)]
pnou has quit [Read error: 104 (Connection reset by peer)]
pnou has joined #ocaml
shirogane has joined #ocaml
samx has joined #ocaml
bd__ is now known as bd_
<schlick> On this "first class functions with closures" thing... It amounts to basically returning data structures from functions, such that the function is equivalent to the data structure (if what it returned was fixed you could hard code it)?
pnou has quit [Read error: 110 (Connection timed out)]
TaXules_ has quit [Read error: 110 (Connection timed out)]
samx has quit ["Leaving"]
<schlick> Guess everybody's asleep again.
<Smerdyakov> schlick, on this "structured programming" thing... it amounts basically to generating uses of goto, such that the uses of goto are equivalent to 'while' loops and other structures.
<Smerdyakov> (Though I also think your analogy isn't flexible enough to cover all uses of closures -- it's not just data, it's code as well, since the same variable of function type can reference different code pointers at different times.)
<Smerdyakov> (But even if it were, you'd be missing the point of how language support changes the idiomatic ways in which people code.)\
TaXules has joined #ocaml
pnou has joined #ocaml
<pango> I've found "Structure and Interpretation of Computer Programs" (http://mitpress.mit.edu/sicp/full-text/book/book.html) very good at explaining functional programming paradigm. Too bad I'm lacking time to read more of it
pnou_ has joined #ocaml
pnou has quit [Read error: 104 (Connection reset by peer)]
<pango> work sucks ;)
<vodka-goo> work sucks ;)
<vodka-goo> well, not so much actually.. but these days suck
<pango> they even show how one can revert previous sentence, implementing datastructures with closures
<vodka-goo> so that's very pure lp
<vodka-goo> I'm afraid I don't believe in _pure_ fp
<vodka-goo> s/lp/fp/
<pango> I doubt I'll use this trick often, but I think it's important to have seen it once, to understand that there's more to functional programming than hof ;)
<pango> (it was rather anecdotical, they're more useful stuff than that in the book)
<Smerdyakov> Implementing everything with functions is very useful if you want to build large theoretical developments from a small core calculus.
<pango> yes, it also depends on your field
rq has quit ["Leaving"]
<pango> but no doubt someone interested in language design should read at least some books on functional paradigm ;)
<pango> Looking at the "99 bottles" site, it's depressing how many languages are no better than 60's algol (and usually worse ;) )
<schlick> Smerdyakov: I went idle when I thought nobody was around. I'd never heard the big academic sounding name before, but I'd seen the same thing done with Lisp. I just didn't know what you were talking about before. I read that it was actually returning a function along with the data but didn't see any way to use it. It looked like it was just equivalent to the data structure itself.
kmag has joined #ocaml
<Smerdyakov> schlick, right, like compiled structured code is equivalent to versions using 'goto.'
<schlick> And actually yes, I understand how it's useful, though you might not like how I'd describe it. It's sort of like pipes at the shell. It's nice for feeding the output of one function into another for it to mangle.
<Smerdyakov> It's nice for pretty much everything.
<Smerdyakov> You don't need loops anymore when you have first-class functions.
<schlick> So how is it you get at the function that's being returned?
<Smerdyakov> You call it....
<schlick> Can you show me a line of ML code that does that?
<Smerdyakov> let rec map f = function [] -> [] | x :: t -> f x :: map f t
<schlick> Hmm, going to have to learn more ML to understand that.
<Smerdyakov> All functions are first-class in ML. If you've seen any function calls, you've seen it.
<Smerdyakov> If you can't follow that, then you definitely need to learn ML. You can't know much of it at all, since that is a very simple example.
<schlick> Not exactly sure what makes them "first class" other than in most non-functional languages (sounds funny worded that way) you can only pass the base data types around, not structures. Is that the difference?
<Smerdyakov> Not all languages let you store a function in a variable.
<Smerdyakov> Basically, something that is on the same general footing with integers in a language is first-class.
<schlick> Yeah, like in C, you'd be able to use a pointer to a function, but you can't do that in most languages.
* Smerdyakov out.
<schlick> So basically what's ment by "first class" in this case is you can treat functions like data? Brings up scary things like self modifying code, though I suspect one doesn't imply the other.
<pango> ocaml doesn't allow self modifying code
<kmag> but it does allow code that generates code
<kmag> which is very powerful
<pango> compiled code doesn't embed any ocaml interpreter or compiler
<schlick> Been wondering about that. Heard about the O'Haskell thing, and if I understood right they achieved objects (local side effects) via self modifying code. I'd be interested if my understanding of that was right.
<schlick> kmag Code that generates code in what way? The generate and eval way, as is common in Lisp?
<schlick> kmag: Or are you talking about the first class functions with closures thing?
pango is now known as pangon8
vodka-goo has quit ["Connection reset by by pear"]
batdog|gone is now known as batdog
batdog is now known as batdog|gone
bzzbzz has joined #ocaml
pango_ has joined #ocaml
pangon8 has quit [Read error: 110 (Connection timed out)]
rq has joined #ocaml
<kmag> schlick: I was talking about closures. (sorry for the delay)
Snark has joined #ocaml
batdog|gone is now known as batdog
batdog is now known as batdog|gone
batdog|gone is now known as batdog
khaladan has joined #ocaml
batdog is now known as batdog|gone
_fab has joined #ocaml
ucla_will has joined #ocaml
Skal has joined #ocaml
ucla_will has quit ["Leaving"]
shirogane has quit [Remote closed the connection]
pango_ has quit [Remote closed the connection]
pango has joined #ocaml
erik has left #ocaml []
<lispy> it looks like F# is based on ocaml
<pango> lispy: it is
<pango> it's ocaml flat ;)
<lispy> i keep wanting to learn ocaml and do some serious programming with it, but then i look at the syntax and wish it had more in common with haskell
<lispy> i wish i could use the haskell declarative syntax to define ocaml functions
<pango> haven't used Haskell
<lispy> the syntax is better, but the performance is worse ;)
<lispy> that is of course an over simplification of the differences
mrpingouin has joined #ocaml
<kmag> does F# support partia function application?
<kmag> *partial
revision17_ has joined #ocaml
Revision17 has quit [Connection timed out]
Snark has quit ["Leaving"]
ppsmimou has joined #ocaml
ppsmimou has quit ["Leaving"]
ppsmimou has joined #ocaml
haakonn has joined #ocaml
<haakonn> i get: "This expression has type
<haakonn> State.t ->
<haakonn> [< `CONJ of int Types.conjunction
<haakonn> | `DOM of int Types.atom
<haakonn> | `SINGLE of int Types.atom ] ->
<haakonn> unit but is here used with type State.report" but State.report is defined as t -> [ `CONJ of int Types.conjunction | `DOM of int Types.atom | `SINGLE of int Types.atom ] -> unit. how is that not a type match?
<haakonn> (oops, didn't mean to paste all the linebreaks)
_fab has quit []
<haakonn> never mind my problem, it was an interface issue. feels dumb to have to repeat type definitions in .mli and .ml
joshcryer has joined #ocaml
lightstep has joined #ocaml
lightstep has quit ["leaving"]
haakonn has left #ocaml []
mrpingouin has quit ["Leaving"]
__DL__ has joined #ocaml
<kmag> pango: hmm... F# doesn't support functiors
<kmag> pango: which is how I would have guessed partial function application would be implemented in a .NET language
<vincenz> kmag: yeah I think it's ocaml without the module or oo system
rillig has joined #ocaml
exa has joined #ocaml
<Schmurtz> vincenz, there is a OO support
<vincenz> oh
<vincenz> didn't know
<Schmurtz> however, the goal of MS it to provide a strong typed system
<Schmurtz> not a full ml implementation
<vincenz> ah
<Schmurtz> vincenz, it's needed for the .NET interfaces
<vincenz> *nods*
<vincenz> damn
<Smerdyakov> F# uses .NET OO, not OCaml OO.
<Smerdyakov> And I think it's goofy to talk about "the goal of MS" here. It's "the goal of Don Syme and a short list of collaborators."
<Schmurtz> yes, I was a bit to general
kmagdsick has left #ocaml []
Deffie has joined #ocaml
<Deffie> hi all, i get /usr/lib/ocaml/mysql/mysql.cmi is not a compiled interface when trying to build a source with ocamlopt and ocamlc anyone knows what it means ?
<vincenz> Deffie: compile the mli file first
<vincenz> ocamlc -c mysql.mli
<Deffie> oh :)
robajs has joined #ocaml
<robajs> hello
ski has joined #ocaml
_JusSx_ has joined #ocaml
<_JusSx_> HI OCAML ppl
<Schmurtz> hi _JusSx_
<ski> hello _JusSx_
ulfdoz has quit [Read error: 113 (No route to host)]
ulfdoz has joined #ocaml
<_JusSx_> it's nice to be here with you
robajs has quit [".."]
pango has quit ["Leaving"]
pango has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Read error: 104 (Connection reset by peer)]
malc_ has joined #ocaml
rq has quit ["Leaving"]
ski has quit ["NMI"]
shirogane has joined #ocaml
rillig has quit ["exit(EXIT_SUCCESS)"]
Bigb[a]ng is now known as Bigbang
ski has joined #ocaml
ppsmimou has quit ["Leaving"]
vincenz has quit ["Lost terminal"]
vincenz has joined #ocaml
Deffie has quit [Read error: 104 (Connection reset by peer)]
smimou has joined #ocaml
mercury^ has joined #ocaml
mercury^ has left #ocaml []
Bigbang is now known as Bigb[a]ng
Bigb[a]ng is now known as Bigbang
rq has joined #ocaml
aegray_ has joined #ocaml
Bigbang is now known as Bigb[a]ng
<_JusSx_> let be string_of list a function that converts a string into a list of chars
<_JusSx_> let be string_of_list a function that converts a string into a list of chars
<_JusSx_> and let be list_of_string that convers a list of chars into a string
<_JusSx_> write a function remove_chars : char -> string -> string that removes first chars
<_JusSx_> for example
<_JusSx_> remove_chars '0' "000000000000--remove-cahrs 000';; ";;
<_JusSx_> - : string = "--remove-cahrs 000';;\n"
<vincenz> _JusSx_: homework?
<_JusSx_> no i don't have homework
<_JusSx_> i'm too old for the school
<vincenz> _JusSx_: easy tho
<vincenz> italiano :)
<_JusSx_> yeah i did
<_JusSx_> but i wwould like to know how you can solve the problem
<_JusSx_> si perche?
<vincenz> cosi
<_JusSx_> anche tu?
<vincenz> no pero ci ho visuto alungo
<_JusSx_> dove?
<vincenz> varese
<vincenz> let remove_chars c s =
<vincenz> let l = list_of_string s in
<vincenz> let rec loop l =
<vincenz> match l with
<vincenz> | [] -> []
<_JusSx_> purtroppo ci sono stato solo una volta :)
<vincenz> | a::b -> if a = c then loop b else l
<vincenz> in string_of_list (loop l)
<_JusSx_> vincenz: i think your function does the same work of List.filter
<vincenz> nope
<vincenz> List.filter filters it all
<vincenz> you'd get "--remove-cahrs "
<vincenz> _JusSx_: List.filter would also loop on l
<vincenz> or rather
<vincenz> a::(loop b)
<vincenz> tho most likely with tail recursion
<_JusSx_> vincenz: yeah you're right
<_JusSx_> vincenz: your code is simple that is great
<vincenz> that's why I love ocaml :)
<_JusSx_> i love it too
<vincenz> solutions are always so succint
<vincenz> or whatever the word is
<_JusSx_> i tried to solve it by using List.filter
<_JusSx_> it works but i don't like that code
<vincenz> _JusSx_: how?
<_JusSx_> let remove_chars c str =
<_JusSx_> let s = ref true in
<_JusSx_> let f = function x ->
<_JusSx_> match !s, x == c with
<_JusSx_> true, true -> false
<_JusSx_> | true, false -> s := not !s; true
<_JusSx_> | _, _ -> true
<_JusSx_> in
<_JusSx_> list_of_string (List.filter f (string_of_list str))
<vincenz> yeah
<vincenz> forcing to use List.filter
<malc_> vincenz: erm.. your solution is supposed to work at all, i think not
<vincenz> malc_: why not?
<vincenz> sure it does
<vincenz> _JusSx_: have a string_of_list and list_of_string for me to test with?
haakonn_ has quit [Connection timed out]
<_JusSx_> vincenz: i tested for it
<_JusSx_> vincenz: i tested for you
<vincenz> _JusSx_: works?
<malc_> vincenz: on the second thought yes, it would
<vincenz> thx
<_JusSx_> vincenz: it works
<vincenz> that's the nice thinig, cause it's so succint, it's easy to tell it's bugfree
<_JusSx_> vincenz: http://pastebin.com/457615
<vincenz> thx
<vincenz> if we had typeclasses
<vincenz> we could treat a string like a list
<_JusSx_> haskell treat string as list of chars
<vincenz> yeah
<vincenz> use rafb.net/paste
<vincenz> it's better
<_JusSx_> vincenz: do you know ml?
<_JusSx_> ok i will check that url
<vincenz> ml?
<vincenz> as in sml?
<vincenz> ocaml is ml
<vincenz> rafb is less spam
<vincenz> and if you copy from pastebiin
<vincenz> it adds an extra # between each two lines
<_JusSx_> i see, you can even download pasted code
* vincenz nods
<vincenz> I rather like it
<vincenz> I have it in my quick link in firefox
<_JusSx_> i will add it to my bookmarks
clog has joined #ocaml
Oejet has left #ocaml []
<schlick> Anyone familiar with a good online reference for math symbols?
Raziel has joined #ocaml
Skal has quit ["Client exiting"]
Mathman has left #ocaml []
aegray_ has quit [Read error: 110 (Connection timed out)]