00:28 (join) acquo 00:30 (quit) acquo: Client Quit 02:17 (quit) jao: Ping timeout: 240 seconds 02:27 (join) aLeSD 02:27 aLeSD: hi all 02:42 jonrafkind: hi 02:50 aLeSD: someone could explain me what's lambda ? 02:54 (quit) mheld: Quit: mheld 02:59 jonrafkind: it makes a function 03:00 jonrafkind: like 2 is a number, (lambda (x) x) is a function that accepts one argument and returns the same argument 03:03 (join) mheld 03:08 (quit) mheld: Ping timeout: 264 seconds 03:18 aLeSD: jonrafkind: in racket you use small functions ? 03:18 aLeSD: I mean you try to divide everything in atoms 03:20 jonrafkind: its usually good programming practice to write small functions 03:23 Lajla: aLeSD, 03:24 Lajla: (define (square x) (* x x)) 03:24 aLeSD: hi Lajla 03:24 Lajla: Is actually just sugar for (define square (lambda (x) (* x x)) 03:24 Lajla: In Scheme, you store a function in a variable like any other value. 03:24 Lajla: aLeSD, remember set! ? 03:24 Lajla: You can also do (define x 3) 03:25 Lajla: And later (set! x (lambda (x) (* x x)) 03:25 Lajla: ) 03:25 aLeSD: Lajla, if i can use (define (square x) (* x x)) 03:25 aLeSD: why use (define square (lambda (x) (* x x)) ? 03:26 Lajla: aLeSD, no real reason. 03:26 Lajla: But it does the same. 03:26 aLeSD: you mean that lambda is unusefull ? 03:26 Lajla: aLeSD, it's not where you would usually use lambda. 03:26 Lajla: aLeSD, say you want a function to return another function. 03:26 aLeSD: ok let's remove lambda from racket 03:27 aLeSD: :) 03:27 aLeSD: I don't belive that is the same than define 03:28 Lajla: For instance (define (square-or-double which) (lambda (x) ((cond ((equal? which "square") *) ((equal? which "double") *)) x x))) 03:28 Lajla: If you do (square-or-double "square") it returns a squaring function 03:29 Lajla: If you do (square-or-double "double") it returns a doubling function 03:29 Lajla: aLeSD, the entire language would break apart. 03:29 Lajla: For instance, (let ((x 3) (y 1)) (+ x y)) is traditionally just sugar for ((lambda (x y) (+ x y) 3 1) 03:30 jonrafkind: you wrote * when you meant + 03:30 Lajla: (define (f x) ...) is just rewritten by the compiler to (define f (lambda (x) ...)) 03:30 Lajla: jonrafkind, you are quite correct. 03:30 Lajla: Where did you muster this astute correctness? 03:31 jonrafkind: elementary 03:31 Lajla: I don't get a 'dear lajla'? 03:32 jonrafkind: that will cost $3.50 03:32 aLeSD: ok 03:34 Lajla: I thought Sherlock holmes worked for free. 03:34 Lajla: aLeSD, lambda is such a often used and fundamental part of the language that many people think the name is far to long for such a commonly used thing, and I would agree. 03:35 Lajla: But aLeSD remeber that I told you that for-each was a function and not syntax? 03:35 aLeSD: ok 03:35 aLeSD: i am going slowly 03:35 aLeSD: give me time to learn let set etc 03:35 aLeSD: lol 03:38 (quit) jonrafkind: Ping timeout: 255 seconds 03:40 Lajla: aLeSD: http://codepad.org/cEOQAVyh 04:17 aLeSD: ok 04:17 aLeSD: ?I will use lambda when I want to create a function that doesn't need a name 04:19 aLeSD: Lajla 04:19 Lajla: aLeSD, you will use lambda when you create a function. 04:20 Lajla: Like I said (define (f x) ...) is just sugar for (define f (lambda (x) ...)) 04:20 Lajla: The compiler rewrites it to the latter form before proceeding 04:21 aLeSD: Lajla, I will create a calculator 04:21 aLeSD: mmm 04:22 aLeSD: no 04:22 aLeSD: ok I will create the first stuff with fluxus 04:23 aLeSD: I think that you have to be very smart to program in racket 04:23 Lajla: yeah 04:23 aLeSD: how you decide to program the stuff is very important 04:23 Lajla: we're all pro. 04:23 Lajla: Pretty much 04:23 Lajla: It's not really a RAD language. 04:44 (quit) aLeSD: Ping timeout: 240 seconds 06:06 (quit) cataska: Quit: leaving 06:36 (join) masm 07:03 (join) mceier 08:02 (join) MayDaniel 08:46 (quit) masm: Quit: Leaving. 08:53 (join) sunnyps 09:39 (join) jeapostrophe 09:42 (quit) jeapostrophe: Client Quit 09:45 (join) jeapostrophe 09:45 (quit) jeapostrophe: Client Quit 10:05 (join) jeapostrophe 10:05 (quit) Lajla: Read error: Connection reset by peer 10:06 (join) Lajla 10:09 (quit) jeapostrophe: Client Quit 10:28 cky: rudybot: (define (square-or-double type) (let ((func (case type ((square) *) ((double) +)))) (lambda (x) (func x x)))) 10:28 rudybot: cky: your r5rs sandbox is ready 10:28 rudybot: cky: Done. 10:29 cky: rudybot: ((square-or-double 'square) 5) 10:29 rudybot: cky: ; Value: 25 10:29 cky: rudybot: ((square-or-double 'double) 5) 10:29 rudybot: cky: ; Value: 10 10:29 cky: :-D 10:29 cky: (Just my reformulation of Lajla's function.) 10:31 Lajla: cky, yeah, I didn't want to introduce my padawan to symbols just yet. 10:31 cky: :-) 10:31 Lajla: I will do so when he is ready. 10:31 Lajla: And can control his powers better. 10:31 cky: rudybot: (define (square-or-double type) (let ((func (case type (("square") *) (("double") +)))) (lambda (x) (func x x)))) 10:31 rudybot: cky: Done. 10:31 cky: rudybot: ((square-or-double "double") 5) 10:31 rudybot: cky: error: procedure application: expected procedure, given: #; arguments were: 5 5 10:31 Lajla: I sense much fear in him, I fear that his childhood experiences may have clouded his judgement 10:31 cky: Hmpf. Oh well. 10:31 Lajla: lolololololo 10:32 Lajla: I think 10:32 Lajla: that case cannot compare strings 10:32 Lajla: case uses eqv? 10:32 cky: Fail. :-P 10:32 (join) mheld 10:32 cky: Ah. 10:32 Lajla: THis is a part I don't like though. 10:32 Lajla: like that whole member, memq, memv and all. 10:33 Lajla: I would rather use somethinf like (foo (lambda (k) (eqv? k the-value-I-search)) some-list) 10:33 Lajla: Just using a unary predicate. 10:34 cky: Isn't that called find (from SRFI 1)? 10:36 Lajla: Seriously? 10:36 Lajla: Then I totally missed that when reading 1. 10:36 Lajla: I use that, but call it give-first 10:37 Lajla: So that I can name filter... 10:37 Lajla: give-all 10:37 Lajla: I am a sucker for consistency 10:37 cky: Hahahahaha. 10:38 Lajla: Though 10:38 Lajla: I am renaming it to 10:38 Lajla: first-when 10:38 Lajla: En all-when 10:38 Lajla: So that I can be consistent 10:38 Lajla: and have first-while 10:38 Lajla: and all-while 10:39 Lajla: I never liked equal? to be honest. 10:39 Lajla: I mean, what if you invent your own super duper data structure. 10:39 Lajla: Should you update equal? for that? 10:40 Lajla: I also think that code that uses equal? instead of vector-equal? or string-equal?, id est, code that is ignorant about whether it are vectors or strings in that case is generally silly. 10:40 Lajla: Or lists, whatever 10:43 cky: *nods* 10:43 cky: Yeah, I don't know what to do about equal? either. 10:43 cky: I wish there's a formal system for extending equal? 10:43 cky: Kind of like setf-handlers in CL. 10:45 cky: But, kind of pointless, like you say. 10:45 Lajla: cky, yeah, I think it should ust be limited to string-equal, vector-equal, et cetera. 10:45 Lajla: And if you invent some nice fancy datastructure. 10:45 Lajla: Like a Lajla. 10:45 Lajla: Just make a lajla-equal 10:46 cky: That reminds me. 10:46 cky: Making a generic function for equal? could be nice. 10:46 Lajla: And don't go like (define equal? (let ((old equal?)) (lambda xs (if (lajla? (car xs)) (apply lajla-equal? xs) (apply old xs)))))) 10:46 Lajla: Or something silly like that 10:46 Lajla: what do you mean? 10:46 cky: I'm thinking of CLOS-style generic functions. 10:47 cky: So you can specify multiple variants of equal?, each with a different type signature. 10:47 cky: So you could define a (equal? ), (equal? ), (equal? ), etc. 10:48 cky: And after all that, the most generic equal? could just be defined to be eq?. 10:48 Lajla: No, I think that is silly too. 10:48 Lajla: I think that people should just know what they are comparing and use string-equal? vector-equal? et cetera accordingly. 10:49 cky: But that makes it hard to write generic algorithms. :-( 10:49 Lajla: And code that is written so that you do not know that statically is silly most of the time. 10:49 Lajla: It is hard enough as it is. 10:49 Lajla: Because vectors do not cons. 10:49 cky: See, I come from C++, where generic algorithms are used a lot. 10:49 cky: I'm not talking about cons. 10:49 cky: I'm talking about conceptually higher-level operations. 10:49 Lajla: cky, I would disagree that they are more generic than dynamic typing. 10:50 Lajla: Usually it involdes not having to rewrite a function that sorts an array of floats when you already have one that sorts an array of integers. 10:50 Lajla: cky, do you know Haskell, or Ocaml, or any of that type? 10:51 cky: I understand the basic ideas about type inference, if that's what you mean. 10:51 Lajla: Well, not that. 10:51 Lajla: I mean, type variables. 10:51 Lajla: How it shows that C++ templates are silly. 10:51 cky: I vaguely remember those. 10:52 Lajla: I mean, there is no real reason for a function that sorts an array with quicksort to care about what the type of the elements is really. 10:52 cky: Right, as long as the ordering function works correctly, that's all that's required. 10:52 Lajla: YEah 10:53 Lajla: so, this nice Hindly Milner type system leaves that type as a type variable. 10:53 Lajla: So the type of this function is (a -> a -> bool) -> [a] -> [a] 10:53 Lajla: Basically, a is foralled. 10:53 Lajla: Universal quantificationationahaskash 10:54 cky: Heh. 10:54 Lajla: So the sort function is correctly typed, provided that its comparison operator is of type a -> a-> Bool 10:54 Lajla: And its input list of of type [a] 10:54 Lajla: And it also outputs a list of type [a] based on that. 10:55 Lajla: But its greatest asset is 10:55 Lajla: THat it shows just how silly C++ is. :') 10:59 cky: Heh. 11:00 (join) jeapostrophe 11:05 Lajla: cky, but another part is yeah that most (all?) expressions can have some type signature be inferred by the compiler. 11:05 Lajla: THough, the point is that it's not always the one you want. 11:05 Lajla: Like, if you go factorial n = prod [1 .. n] 11:05 Lajla: It infers its type as Int -> Int 11:05 Lajla: But maybe you wanted float -> float 11:06 Lajla: Because prod also works on floats. 11:06 Lajla: And as far as I know, hoaskell does not have a numerical tower like good old scheme 11:10 cky: *nods* 11:33 (quit) Lajla: Ping timeout: 260 seconds 11:35 (quit) jeapostrophe: Quit: jeapostrophe 11:48 (join) Lajla 12:22 (join) anRch 12:48 (quit) MayDaniel: Read error: Connection reset by peer 12:54 (quit) anRch: Quit: anRch 12:56 (quit) sunnyps: Quit: Leaving 13:00 (join) jeapostrophe 13:04 (join) anRch 13:17 (quit) jeapostrophe: Quit: jeapostrophe 13:30 (join) cinch 13:44 (quit) anRch: Quit: anRch 14:08 (join) jonrafkind 14:15 (join) MayDaniel 14:26 (join) jeapostrophe 14:26 (quit) jeapostrophe: Client Quit 14:45 (join) Fare 15:07 (quit) Fare: Quit: Leaving 15:57 (join) mwolfe 16:06 (quit) MayDaniel: Read error: Connection reset by peer 16:45 (quit) em: Read error: Connection reset by peer 16:46 (join) emma 16:48 (nick) emma -> em 16:57 (quit) offby1: Read error: Connection reset by peer 16:58 (join) offby1 17:01 (quit) tv|z: Ping timeout: 240 seconds 17:03 (join) tv|z 17:08 (quit) offby1: Read error: Connection reset by peer 17:08 (join) offby1 17:16 (join) anRch 17:40 (quit) anRch: Quit: anRch 18:13 (join) MayDaniel 18:19 (quit) offby1: Ping timeout: 260 seconds 18:27 (quit) pattern: Ping timeout: 250 seconds 18:28 (join) elly 18:29 (quit) MayDaniel: Read error: Connection reset by peer 18:32 (join) offby1 18:35 elly: is there a good example of a nontrivial program written in Racket that makes use of racket's contract system somewhere? 18:53 jonrafkind: typed racket 19:28 (quit) offby1: Read error: Connection reset by peer 19:28 (quit) mwolfe: Remote host closed the connection 19:29 (join) offby1 20:44 (quit) jonrafkind: Ping timeout: 240 seconds 21:00 (quit) mceier: Quit: leaving 21:09 (join) bremner 21:26 (quit) offby1: Read error: Connection reset by peer 21:43 (join) offby1 21:49 askhader has never used racket's contract system. Just informal contracts found within comments 22:07 (join) jeapostrophe 22:23 (join) jonrafkind 23:09 (quit) jeapostrophe: Quit: jeapostrophe 23:59 (join) jeapostrophe 23:59 (quit) jeapostrophe: Client Quit