2014-10-11T00:01:32Z lrs quit (Ping timeout: 245 seconds) 2014-10-11T00:07:21Z leb joined #scheme 2014-10-11T00:15:02Z ehaliewicz quit (Ping timeout: 255 seconds) 2014-10-11T00:19:03Z mrowe_away is now known as mrowe 2014-10-11T00:27:39Z c107 joined #scheme 2014-10-11T00:28:36Z mrowe is now known as mrowe_away 2014-10-11T00:56:27Z daviid quit (Remote host closed the connection) 2014-10-11T01:01:20Z robot-beethoven joined #scheme 2014-10-11T01:04:09Z jusss joined #scheme 2014-10-11T01:19:50Z mrowe_away is now known as mrowe 2014-10-11T01:27:06Z leo2007 quit (Remote host closed the connection) 2014-10-11T01:27:19Z finnrobi quit (Ping timeout: 272 seconds) 2014-10-11T01:29:38Z mrowe is now known as mrowe_away 2014-10-11T01:29:40Z leo2007 joined #scheme 2014-10-11T01:33:07Z Shadox quit (Quit: Leaving) 2014-10-11T01:34:03Z tobik_ joined #scheme 2014-10-11T01:34:03Z tobik quit (Ping timeout: 272 seconds) 2014-10-11T01:34:14Z tobik_ is now known as tobik 2014-10-11T01:34:17Z Vutral quit (Ping timeout: 260 seconds) 2014-10-11T01:36:12Z Vutral joined #scheme 2014-10-11T01:52:21Z aranhoide joined #scheme 2014-10-11T01:54:22Z nowhere_man quit (Read error: Connection reset by peer) 2014-10-11T01:55:50Z nowhere_man joined #scheme 2014-10-11T01:58:14Z finnrobi joined #scheme 2014-10-11T02:04:15Z sbwhitecap joined #scheme 2014-10-11T02:18:32Z pjb quit (Ping timeout: 244 seconds) 2014-10-11T02:27:15Z stepnem quit (Ping timeout: 272 seconds) 2014-10-11T02:29:50Z pjb joined #scheme 2014-10-11T02:30:39Z wilfredh quit (Quit: Connection closed for inactivity) 2014-10-11T02:30:42Z aranhoide quit (Ping timeout: 245 seconds) 2014-10-11T02:41:49Z BossKonaSegwaY quit (Ping timeout: 272 seconds) 2014-10-11T02:42:04Z leb quit (Quit: Computer has gone to sleep.) 2014-10-11T02:56:12Z jlongster quit (Read error: Connection reset by peer) 2014-10-11T02:56:42Z BossKonaSegwaY joined #scheme 2014-10-11T02:59:38Z jusss quit (Remote host closed the connection) 2014-10-11T03:01:54Z davexunit quit (Quit: Later) 2014-10-11T03:05:33Z kongtomorrow joined #scheme 2014-10-11T03:06:06Z alexei___ joined #scheme 2014-10-11T03:09:10Z alexei_ quit (Ping timeout: 244 seconds) 2014-10-11T03:20:08Z b4283 joined #scheme 2014-10-11T03:24:18Z kongtomorrow quit (Read error: Connection reset by peer) 2014-10-11T03:24:22Z kongtomo_ joined #scheme 2014-10-11T03:34:12Z kongtomo_ quit 2014-10-11T03:41:11Z kongtomorrow joined #scheme 2014-10-11T03:44:20Z kongtomorrow quit (Client Quit) 2014-10-11T04:11:56Z pjb quit (Ping timeout: 260 seconds) 2014-10-11T04:23:23Z araujo quit (Quit: Leaving) 2014-10-11T04:25:13Z Sgeo_ quit (Read error: Connection reset by peer) 2014-10-11T04:26:38Z Sgeo joined #scheme 2014-10-11T04:57:14Z jusss joined #scheme 2014-10-11T05:02:28Z pjdelport quit (Quit: Connection closed for inactivity) 2014-10-11T05:16:27Z sigjuice: I am having trouble with SICP exercise 3.39. http://sarabander.github.io/sicp/html/3_002e4.xhtml#Exercise-3_002e39 2014-10-11T05:17:30Z sigjuice: When I run the code, x ends up as 11 sometimes. I just don't see how that is possible. Any suggestions? 2014-10-11T05:17:51Z pera quit (Ping timeout: 272 seconds) 2014-10-11T05:20:22Z mrowe_away is now known as mrowe 2014-10-11T05:34:53Z b4283 quit (Quit: Konversation terminated!) 2014-10-11T05:42:05Z sigjuice: Here is the code I tried. http://tinyurl.com/mz2egjv 2014-10-11T05:43:21Z fantazo joined #scheme 2014-10-11T05:47:12Z pjb joined #scheme 2014-10-11T05:59:09Z mrowe is now known as mrowe_away 2014-10-11T06:03:33Z jeapostrophe quit (Ping timeout: 260 seconds) 2014-10-11T06:21:17Z masm joined #scheme 2014-10-11T06:28:59Z joneshf-laptop joined #scheme 2014-10-11T06:31:10Z pjb` joined #scheme 2014-10-11T06:31:15Z chaotic_good joined #scheme 2014-10-11T06:31:56Z pjb is now known as ogamita 2014-10-11T06:32:06Z pjb` is now known as pjb 2014-10-11T06:49:40Z Kabaka quit (Quit: s/Kabaka//) 2014-10-11T06:53:07Z c107 quit (Remote host closed the connection) 2014-10-11T07:06:07Z oleo is now known as Guest91337 2014-10-11T07:06:19Z jusss quit (Read error: Connection reset by peer) 2014-10-11T07:07:43Z oleo__ joined #scheme 2014-10-11T07:09:03Z Guest91337 quit (Ping timeout: 255 seconds) 2014-10-11T07:16:47Z Kabaka joined #scheme 2014-10-11T07:20:04Z jusss joined #scheme 2014-10-11T07:20:05Z kongtomorrow joined #scheme 2014-10-11T07:39:46Z jusss quit (Read error: No route to host) 2014-10-11T07:41:46Z jusss joined #scheme 2014-10-11T07:45:06Z kongtomorrow quit 2014-10-11T07:54:47Z ogamita quit (Quit: ERC Version 5.3 (IRC client for Emacs)) 2014-10-11T08:01:36Z fantazo quit (Ping timeout: 244 seconds) 2014-10-11T08:15:51Z stepnem joined #scheme 2014-10-11T08:15:51Z Riastradh quit (Ping timeout: 264 seconds) 2014-10-11T08:25:59Z chaotic_good quit (Quit: Lost terminal) 2014-10-11T08:41:13Z kuribas joined #scheme 2014-10-11T08:48:23Z gravicappa joined #scheme 2014-10-11T08:50:20Z Gyps quit (Quit: Gyps) 2014-10-11T09:07:08Z bjz joined #scheme 2014-10-11T09:17:57Z lrs joined #scheme 2014-10-11T09:27:54Z civodul joined #scheme 2014-10-11T09:34:17Z kongtomorrow joined #scheme 2014-10-11T09:36:04Z robot-beethoven quit (Quit: ERC Version 5.3 (IRC client for Emacs)) 2014-10-11T09:37:35Z hiroakip joined #scheme 2014-10-11T09:37:37Z lrs: Im trying to do a repeating function 2014-10-11T09:38:10Z lrs: That when f(x)=x+1 2014-10-11T09:38:20Z lrs: ((repeated f 3) 1) = 4 2014-10-11T09:38:30Z lrs: (define (repeated f n) 2014-10-11T09:38:30Z lrs: (if (= n 1) 2014-10-11T09:38:30Z lrs: f 2014-10-11T09:38:30Z lrs: (lambda (x) (repeated f ( - n 1))))) 2014-10-11T09:38:34Z lrs: This is what I have done so far 2014-10-11T09:41:57Z drdanmaku quit (Quit: Connection closed for inactivity) 2014-10-11T09:42:30Z kongtomorrow quit 2014-10-11T09:44:02Z jusss quit (Ping timeout: 245 seconds) 2014-10-11T09:47:49Z pjb: What if n = 0 or is negative? 2014-10-11T09:48:01Z pjb: You need to call the repeated n-1 function. 2014-10-11T09:48:14Z lrs: What do you suggest i do 2014-10-11T09:49:12Z pjb: lrs: scheme is strongly typed a programming language. The types are not associated to the variables, but to the values, but they still exist. So when you write code, you should always think about the type of the values you are processing, and you should ensure that the types of your expressions are consistent. 2014-10-11T09:49:59Z lrs: What are types? 2014-10-11T09:50:12Z pjb: functions, integers, symbols, lists, etc. 2014-10-11T09:50:32Z lrs: Ok 2014-10-11T09:50:49Z pjb: If f is a function integer -> integer, then (repeated f n) will return a function integer -> integer. 2014-10-11T09:51:22Z pjb: But the lambda that you wrote is a function integer -> function(integer->integer), instead of a function integer->integer. 2014-10-11T09:52:00Z lrs: Well 2014-10-11T09:52:06Z pjb: You would want to call it, on the result of (f x): (repeated f n) = (lambda (x) ((repeated f (- n 1)) (f x))) 2014-10-11T09:52:11Z lrs: Its value at x is f(f(...(f(x))...)) 2014-10-11T09:52:18Z pjb: Yes. 2014-10-11T09:52:37Z lrs: Ah right 2014-10-11T09:52:37Z pjb: f^n(x) is integer->integer when f is integer->integer. 2014-10-11T09:53:13Z pjb: f^0(x) = id(x) = x usually. 2014-10-11T09:53:29Z lrs: (define (repeated f n) 2014-10-11T09:53:29Z lrs: (if (= n 1) 2014-10-11T09:53:30Z lrs: f 2014-10-11T09:53:30Z lrs: (lambda (x) (repeated f ( - n 1)) (f x)))) 2014-10-11T09:53:46Z pjb: f^-1 is the inverse of the function, which works only if the function is surjective, and which is too complex to compute in general. 2014-10-11T09:53:59Z pjb: Here you don't call (repeated f (- n 1)). 2014-10-11T09:54:28Z mutley89 quit (Ping timeout: 260 seconds) 2014-10-11T09:54:30Z pjb: In Lisp, to call a function you must use parentheses, and when you use parentheses, you apply an operator (call a function, macroexpand a macro, apply a special operator). 2014-10-11T09:54:49Z pjb: (lambda (x) ((repeated f (- n 1)) (f x))) 2014-10-11T09:55:33Z lrs: Right 2014-10-11T09:58:09Z lrs: I dont know what macroexpnasion is htough 2014-10-11T09:58:27Z lrs: But how do I define and call this function 2014-10-11T09:58:30Z lrs: Because now I can write 2014-10-11T09:59:09Z lrs: (define g (repeated f 3)) 2014-10-11T09:59:20Z lrs: But it gives me f is undefined 2014-10-11T10:01:38Z pjb: lrs: macroexpansion occurs is when you use a macro (define-syntax in r5rs). 2014-10-11T10:02:12Z pjb: It's not covered in sicp, but it allows one other abstraction: syntactic abstraction, which can be used with metalinguistic abstraction (covered in chapter 4). 2014-10-11T10:02:25Z pjb: lrs: probably you need to define a f first. 2014-10-11T10:02:38Z pjb: (define f (lambda (x) (+ x 1))) 2014-10-11T10:04:11Z atomx joined #scheme 2014-10-11T10:04:15Z atomx quit (Remote host closed the connection) 2014-10-11T10:04:49Z lrs: pjb 2014-10-11T10:04:51Z lrs: Ok so 2014-10-11T10:04:54Z lrs: I should do 2014-10-11T10:05:00Z lrs: (define f (lambda (x) (+ x 1))) 2014-10-11T10:05:03Z lrs: And then when I do 2014-10-11T10:05:08Z lrs: ((repeated f 3) 1) 2014-10-11T10:05:11Z lrs: Its supposed to be 4 2014-10-11T10:05:16Z pjb: Yes. 2014-10-11T10:05:17Z lrs: But now its 2 2014-10-11T10:06:12Z atomx joined #scheme 2014-10-11T10:06:35Z lrs: What am I doing wrong 2014-10-11T10:07:44Z pjb: Works for me: http://paste.lisp.org/+3343 2014-10-11T10:08:10Z pjb: You didn't call (repeated f (- n 1)) as I've been told now three times. 2014-10-11T10:08:16Z lrs: Why do you have two lamda x x 2014-10-11T10:08:27Z pjb: Because I handle the case where n=0. 2014-10-11T10:08:34Z pjb: f^0 = identity. 2014-10-11T10:09:53Z lrs: Well, your owrks 2014-10-11T10:10:22Z lrs: pjb, Can you please expain 1) The = 0 stuff, why you have (lambda (x) x) and why you have the (- n 1) 2014-10-11T10:10:48Z pjb: What do you get if you call f 0 times on x? 2014-10-11T10:11:31Z lrs: What x 2014-10-11T10:11:37Z pjb: Any x. 2014-10-11T10:11:38Z pjb: f^3, 3 times: f(f(f(x))) 2014-10-11T10:11:43Z pjb: f^2, 2 times: f(f(x)) 2014-10-11T10:11:47Z lrs: 0? 2014-10-11T10:11:49Z pjb: f^1, 1 times: f(x) 2014-10-11T10:11:54Z pjb: f^0, 0 times: ? 2014-10-11T10:12:07Z vanila joined #scheme 2014-10-11T10:12:19Z pjb: f(f(f(x))) -> f(f(x)) -> f(x) -> ? 2014-10-11T10:12:36Z pjb: why would the next result be 0? 2014-10-11T10:12:40Z pjb: It's not logical. 2014-10-11T10:13:00Z lrs: (f(0) 0) 2014-10-11T10:13:00Z lrs: ? 2014-10-11T10:13:09Z pjb: This is meaningless. 2014-10-11T10:13:27Z pjb: f can be any function. Perhaps it's the function that takes birds, and return the bird's egg. 2014-10-11T10:14:10Z lrs: And if there is no function 2014-10-11T10:14:30Z pjb: Yes, if you don't use f at all, on x, what do you have? 2014-10-11T10:14:42Z lrs: f(x) 2014-10-11T10:14:43Z lrs: ? 2014-10-11T10:14:50Z pjb: If you use f once on x, you get f(x). 2014-10-11T10:14:52Z lrs: Or nothing at all 2014-10-11T10:15:02Z pjb: But if you don't use f on x, what do you get? 2014-10-11T10:15:12Z lrs: x? 2014-10-11T10:15:14Z pjb: Ok, so let's try with equations. 2014-10-11T10:16:34Z pjb: let i = (lambda (x) x) 2014-10-11T10:16:39Z pjb: i is the identity function. 2014-10-11T10:16:43Z pjb: i(x) = x. 2014-10-11T10:17:04Z pjb: f^2(x) = f(f(x)) = f(f(i(x))), right? 2014-10-11T10:17:45Z lrs: Yes 2014-10-11T10:17:47Z pjb: f^1(x) = f(x) = f(i(x)), right? 2014-10-11T10:17:51Z lrs: Yep 2014-10-11T10:18:01Z pjb: f^0(x) = ? = ? 2014-10-11T10:18:14Z pjb: would you say that f^0(x) = i(x) ? 2014-10-11T10:18:23Z lrs: Yes 2014-10-11T10:18:26Z pjb: good. 2014-10-11T10:18:34Z pjb: So f^0(x) = i(x) = x 2014-10-11T10:18:42Z pjb: f^0 = i 2014-10-11T10:19:11Z pjb: Now, f^1 = fof^0 = foi = f 2014-10-11T10:19:48Z pjb: f^n = fof^(n-1) for all n-1>=0 <=> n>0 2014-10-11T10:20:02Z pjb: and f^0 = i 2014-10-11T10:20:13Z pjb: this gives us the recursion equations. 2014-10-11T10:20:55Z pjb: if n=0 then i else fof^(n-1) 2014-10-11T10:21:22Z pjb: (if (= 0 n) (lambda (x) x) (lambda (x) (f ((repeated f (- n 1)) x)))) 2014-10-11T10:21:40Z pjb: fof^(n-1) = f^n = f^(n-1)of 2014-10-11T10:21:53Z pjb: so you can also write (if (= 0 n) (lambda (x) x) (lambda (x) ((repeated f (- n 1)) (f x)))) 2014-10-11T10:23:04Z pjb: You could also (define (compose f g) (lambda (x) (f (g x)))) 2014-10-11T10:23:16Z pjb: (define (identity x) x) 2014-10-11T10:23:30Z pjb: (if (= 0 n) identity (compose f (repeated f (- n 1)))) 2014-10-11T10:24:14Z lrs: f^1 = fof^0 = foi = f ? 2014-10-11T10:24:18Z lrs: What is fo 2014-10-11T10:24:33Z pjb: o is the function composition operator. 2014-10-11T10:24:41Z pjb: fog = (lambda (x) (f (g x))) 2014-10-11T10:27:18Z lrs: So lambda is the function composion operator? 2014-10-11T10:28:33Z pjb: O. 2014-10-11T10:28:34Z pjb: No. 2014-10-11T10:28:49Z pjb: lambda is the operator that lets you introduce anonymous functions. 2014-10-11T10:29:08Z pjb: In math: fog : x |--> f(g(x)) 2014-10-11T10:29:31Z pjb: x|-->e(x) is written λx.e(x) or (lambda (x) (e x)) 2014-10-11T10:30:13Z pjb: maths Church lisp 2014-10-11T10:31:21Z vanila: Another way to write 'repeated' that might be easier to understand is this way: 2014-10-11T10:31:26Z vanila: (define (repeated f n x) 2014-10-11T10:31:30Z vanila: (if (= n 0) 2014-10-11T10:31:37Z vanila: x 2014-10-11T10:31:39Z wingo joined #scheme 2014-10-11T10:31:46Z vanila: (f (repeated f (- n 1) x))))) 2014-10-11T10:32:51Z vanila: Hi wingo 2014-10-11T10:32:59Z wingo: greets 2014-10-11T10:33:23Z vanila: I'm learning about scheme compilers and i've been following your blog, which has be really interesting and useful - thank you! :) 2014-10-11T10:33:42Z wingo: thanks for the kind words :) 2014-10-11T10:35:32Z lrs: vanila, Hm 2014-10-11T10:36:05Z lrs: vanila, Whats the difference 2014-10-11T10:36:40Z vanila: This takes 3 parameters and computes a result 2014-10-11T10:36:56Z vanila: the one pjb wrote takes 2 and produces a function that will compute a result when you give it 'x' 2014-10-11T10:39:53Z lrs: vanila, And the funtion in this case is uh 2014-10-11T10:40:04Z lrs: The function that will compute 2014-10-11T10:41:02Z vanila: (repeated double 0 1) ;=> 2 2014-10-11T10:41:06Z vanila: (repeated double 1 1) ;=> 4 2014-10-11T10:41:09Z vanila: (repeated double 2 1) ;=> 8 2014-10-11T10:41:27Z vanila: you can try this in the REPL 2014-10-11T10:41:55Z vanila: (repeated reverse 0 '(#\h #\i)) ;=> (#\h #\i) 2014-10-11T10:42:00Z vanila: (repeated reverse 1 '(#\h #\i)) ;=> (#\i #\h) 2014-10-11T10:42:04Z vanila: (repeated reverse 2 '(#\h #\i)) ;=> (#\h #\i) 2014-10-11T10:42:19Z vanila: see if you can get it to give you the same results 2014-10-11T10:44:35Z lrs: double is defined as 2014-10-11T10:45:52Z lrs: x+x i assue 2014-10-11T10:46:03Z lrs: Does work 2014-10-11T10:46:04Z lrs: Meh 2014-10-11T11:15:06Z sbwhitecap quit (Quit: Leaving...) 2014-10-11T11:15:13Z BossKonaSegwaY quit (Ping timeout: 260 seconds) 2014-10-11T11:18:24Z oleo__ quit (Quit: Verlassend) 2014-10-11T11:19:24Z alexei___ quit (Ping timeout: 260 seconds) 2014-10-11T11:26:50Z oleo joined #scheme 2014-10-11T11:27:22Z bjz quit (Ping timeout: 240 seconds) 2014-10-11T11:37:36Z BossKonaSegwaY joined #scheme 2014-10-11T11:47:13Z kongtomorrow joined #scheme 2014-10-11T11:52:51Z bjz joined #scheme 2014-10-11T11:56:19Z bokr joined #scheme 2014-10-11T12:00:38Z hiroakip quit (Ping timeout: 255 seconds) 2014-10-11T12:12:40Z kuribas quit (Quit: ERC Version 5.3 (IRC client for Emacs)) 2014-10-11T12:16:48Z hiroakip joined #scheme 2014-10-11T12:21:35Z mutley89 joined #scheme 2014-10-11T12:22:20Z civodul quit (Quit: ERC Version 5.3 (IRC client for Emacs)) 2014-10-11T12:26:02Z amgarchIn9 joined #scheme 2014-10-11T12:33:02Z hiroakip quit (Ping timeout: 255 seconds) 2014-10-11T12:39:03Z mutley89 quit (Ping timeout: 244 seconds) 2014-10-11T12:50:41Z vanila quit (Remote host closed the connection) 2014-10-11T12:54:44Z pera joined #scheme 2014-10-11T13:10:48Z Nizumzen joined #scheme 2014-10-11T13:11:57Z kongtomorrow quit 2014-10-11T13:33:31Z bokr quit (Quit: Leaving.) 2014-10-11T13:38:03Z guampa quit (Ping timeout: 264 seconds) 2014-10-11T13:41:59Z taylanub quit (Disconnected by services) 2014-10-11T13:42:37Z taylanub joined #scheme 2014-10-11T13:45:02Z guampa joined #scheme 2014-10-11T13:46:56Z ogamita joined #scheme 2014-10-11T14:12:06Z jusss joined #scheme 2014-10-11T14:17:43Z atomx_ joined #scheme 2014-10-11T14:18:32Z atomx_ quit (Remote host closed the connection) 2014-10-11T14:18:57Z atomx quit (Ping timeout: 245 seconds) 2014-10-11T14:19:35Z atomx joined #scheme 2014-10-11T14:24:09Z CaptainRant joined #scheme 2014-10-11T14:24:36Z CaptainRant: Are there any naming conventions in scheme ? Should i prefer (foo/bar ...) over (foo.bar ...) ? 2014-10-11T14:27:00Z pjb: CaptainRant: nothing general that I'm aware of. You can use your own convention. 2014-10-11T14:27:22Z pjb: foo-bar can be good too. 2014-10-11T14:32:42Z Sgeo quit (Read error: Connection reset by peer) 2014-10-11T14:48:48Z pera quit (Quit: leaving) 2014-10-11T14:52:53Z lrs: I need some help 2014-10-11T14:53:13Z lrs: Im trying to create a consturctor, selector and predicate 2014-10-11T14:53:24Z lrs: That creates sets 2014-10-11T14:56:22Z lrs: Basically its gonna create a set from example : define myset 2014-10-11T14:56:22Z lrs: (make-set '(a (a b b (c b) 3) 5 5 (e s) (s e s)))) 2014-10-11T14:56:32Z lrs: And remove the multiple instances 2014-10-11T14:57:45Z CaptainRant: Fold over the list and add your values to a hash table, so you can check if you have it already in your list. 2014-10-11T14:58:43Z lrs: I think hash tables is a bit too advanced for me 2014-10-11T14:59:08Z CaptainRant: In which regard ? You just need to know 3 functions. 2014-10-11T14:59:39Z CaptainRant: You can even skip the fold part and just add each value to the table, so duplicates will simply be overridden. 2014-10-11T14:59:43Z lrs: In regard to the fact I dont know what a hashtable is 2014-10-11T15:00:14Z CaptainRant: It associates a value with another, but is faster than a alist when doing lookups. 2014-10-11T15:00:35Z CaptainRant: So you can map "foo" to 42, and check very quickly if its mapped and to what. 2014-10-11T15:00:50Z CaptainRant: Hash tables are usually O(1) 2014-10-11T15:01:10Z CaptainRant: I guess your implementation provides srfi-69. 2014-10-11T15:01:42Z lrs: Whats srfi-69 2014-10-11T15:01:56Z CaptainRant: The srfi that describes hash tables. 2014-10-11T15:02:27Z CaptainRant: Its basically a scheme extension, that most implementations provide. 2014-10-11T15:02:46Z lrs: I use DrRacket nad "pretty big" 2014-10-11T15:03:14Z CaptainRant: DrRacket has everything and a kitchensink. It maybe even have already what you want. 2014-10-11T15:03:27Z CaptainRant: has* 2014-10-11T15:03:28Z lrs: Yeah, maybe 2014-10-11T15:03:34Z lrs: But the point is that I learn 2014-10-11T15:03:37Z lrs: How to do it 2014-10-11T15:04:12Z CaptainRant: Do you want to deduplicate only the lists, or recursively all contents of the list ? 2014-10-11T15:04:43Z lrs: Sorry, my english is bad 2014-10-11T15:04:45Z lrs: What do you mean 2014-10-11T15:05:11Z hiroakip joined #scheme 2014-10-11T15:05:13Z CaptainRant: So if you have (a (a b) (b c)), do you want just (a b c) ? 2014-10-11T15:06:34Z lrs: (a (a b) (b c)) No 2014-10-11T15:06:36Z lrs: I mean 2014-10-11T15:06:38Z lrs: Uh 2014-10-11T15:06:42Z lrs: If I get (a (a b) (b c)) 2014-10-11T15:06:44Z lrs: I want (a (a b) (b c)) 2014-10-11T15:06:46Z lrs: If I get 2014-10-11T15:06:49Z lrs: (a (a b b) (b c)) 2014-10-11T15:06:50Z CaptainRant: ah, ok 2014-10-11T15:06:50Z lrs: I want (a (a b) (b c)) 2014-10-11T15:07:42Z CaptainRant: So you can avoid hash tables and sort each sublist. So you can iterate over it and cons only if your element differs from the previous one. 2014-10-11T15:08:06Z lrs: I guess so 2014-10-11T15:08:10Z CaptainRant: If you want to dedup (a b a c), you sort it to (a a b c), and then fold out to (a b c) 2014-10-11T15:08:29Z lrs: Yes 2014-10-11T15:08:29Z CaptainRant: And this for all lists, sublists, sub-sublists, ... 2014-10-11T15:09:31Z lrs: Right 2014-10-11T15:10:34Z lrs: So I first use sort 2014-10-11T15:14:42Z lrs: CaptainRant, How would you do this? 2014-10-11T15:16:29Z CaptainRant: Recurse over all sublists, and map (dedup (sort list)) over. 2014-10-11T15:20:55Z lrs: CaptainRant, Ugh 2014-10-11T15:20:56Z lrs: I suck ass 2014-10-11T15:21:01Z lrs: Can you give me some code 2014-10-11T15:21:52Z karswell` quit (Ping timeout: 245 seconds) 2014-10-11T15:22:47Z CaptainRant: wait :G 2014-10-11T15:27:41Z CaptainRant: Is the ordering importand inside the sublists ? 2014-10-11T15:29:19Z CaptainRant: i can't give you some code, there is maybe anything on google out there. Sorry. 2014-10-11T15:30:08Z CaptainRant: You can use (partition list? your-list) To split your list into elements and sublists. 2014-10-11T15:30:19Z lrs: Ordering is I guess.. normal. 1 2 3 2014-10-11T15:32:28Z leo2007 quit (Quit: rcirc on GNU Emacs 25.0.50.5) 2014-10-11T15:32:46Z CaptainRant: Then you sort and deduplicate your elements, and append the result of mapping the same function over the sublists. 2014-10-11T15:33:32Z lrs: So I start with 2014-10-11T15:33:33Z lrs: (sort l >) 2014-10-11T15:34:39Z CaptainRant: Pseudocode: (define (your-foo list) (define-values (sublists elements) (partition list? list))(append (dedup (sort elements)) (map your-foo sublists)) 2014-10-11T15:35:56Z leo2007 joined #scheme 2014-10-11T15:40:50Z lrs: CaptainRant, 2014-10-11T15:41:04Z lrs: Is there any way I can use something else than dedup? 2014-10-11T15:41:57Z CaptainRant: you must implement dedup, which is basically a fold, a cons and if (eq? current-element (car new-sublis)) 2014-10-11T15:42:28Z wingo quit (Ping timeout: 244 seconds) 2014-10-11T15:44:58Z cheater__ joined #scheme 2014-10-11T15:45:01Z cheater__ is now known as cheater 2014-10-11T15:45:23Z lrs: CaptainRant, Is there anything other to use than fold? 2014-10-11T15:45:40Z lrs: All the stuff you use is stuff that I dont I have used in the course im doing 2014-10-11T15:45:46Z CaptainRant: for-each and set! maybe, but thats imperative 2014-10-11T15:45:52Z atomx quit (Ping timeout: 260 seconds) 2014-10-11T15:45:56Z lrs: for-each I think 2014-10-11T15:46:23Z CaptainRant: I don't know which course you are doing, im just a random guy doing some random scheme coding and rant in irc :P 2014-10-11T15:46:49Z lrs: Yeah, well 2014-10-11T15:46:52Z lrs: My point is 2014-10-11T15:46:55Z lrs: Keep it simple 2014-10-11T15:46:57Z lrs: ;_; 2014-10-11T15:47:20Z CaptainRant: Fold is simple, once you grok it. Its THE iterator for lists 2014-10-11T15:48:29Z CaptainRant: Fold takes a lambda as the first arg, the init list as the second and the list which should be iterated over as a last arg. 2014-10-11T15:48:58Z CaptainRant: The lambda takes 2 values: The item you are currently "for-eaching", and the result of the previous iteration. 2014-10-11T15:49:39Z CaptainRant: So if you want to append a list of strings, you do: (fold string-append "" '("Hello" " " "world" ".")) 2014-10-11T15:53:10Z _tca: rudybot: (> 'a 5) 2014-10-11T15:53:11Z rudybot: _tca: error: >: contract violation expected: real? given: 'a argument position: 1st other arguments...: 5 2014-10-11T15:53:50Z _tca: you wont be able to sort it with sort if its heterogeneous 2014-10-11T15:54:01Z lrs: (append (dedup (sort l >)) 2014-10-11T15:54:16Z lrs: How do I create a dedup stuff is the question 2014-10-11T15:55:48Z CaptainRant: (define (dedup list) (fold (lamda (item new-list) (if (eq? item (car new-list)) new-list (cons item new-list))))) 2014-10-11T15:55:55Z CaptainRant: no guarrantee 2014-10-11T15:56:18Z jeapostrophe joined #scheme 2014-10-11T15:56:28Z CaptainRant: i forgot the ... '() list))))) after the fold. And i have no clue if you can car '() 2014-10-11T15:56:35Z _tca: you should do the little schemer 2014-10-11T15:56:47Z _tca: and no you cant 2014-10-11T15:57:00Z _tca: rudybot: (car '()) 2014-10-11T15:57:00Z rudybot: _tca: error: car: contract violation expected: pair? given: '() 2014-10-11T15:57:12Z lrs: I need some tutorial that works with sets 2014-10-11T15:57:14Z lrs: :S 2014-10-11T15:57:19Z _tca: lrs: it's called "the little schemer" 2014-10-11T15:57:35Z _tca: it's a book for learning scheme specifically made for people with adhd 2014-10-11T15:57:40Z lrs: lol 2014-10-11T15:58:31Z _tca: all of these questions youve asked so far and more are covered in it 2014-10-11T15:59:54Z cheater left #scheme 2014-10-11T15:59:58Z lrs: Downlaoded it 2014-10-11T16:05:56Z ogamita quit (Ping timeout: 260 seconds) 2014-10-11T16:06:27Z pnpuff joined #scheme 2014-10-11T16:07:22Z hiroakip quit (Ping timeout: 240 seconds) 2014-10-11T16:07:53Z pnpuff left #scheme 2014-10-11T16:09:25Z CaptainRant left #scheme 2014-10-11T16:11:02Z hiroakip joined #scheme 2014-10-11T16:13:46Z vanila joined #scheme 2014-10-11T16:17:07Z drdanmaku joined #scheme 2014-10-11T16:17:58Z jusss quit (Quit: ERC Version 5.2 (IRC client for Emacs)) 2014-10-11T16:43:54Z Sgeo joined #scheme 2014-10-11T16:45:18Z lrs: Im stuck 2014-10-11T16:50:31Z leo2007 quit (Ping timeout: 272 seconds) 2014-10-11T17:05:21Z lrs: :| 2014-10-11T17:05:23Z lrs: FUCK 2014-10-11T17:07:11Z vanila: calm down lrs 2014-10-11T17:07:14Z vanila: what is the problem? 2014-10-11T17:07:32Z lrs: Im trying to create a constructor "make-set" 2014-10-11T17:07:39Z lrs: But I dont know how I should do it 2014-10-11T17:09:46Z vanila: (define make-set list) 2014-10-11T17:10:00Z lrs: Thats how far Ive got 2014-10-11T17:17:51Z _tca: lrs: you shouldn't complect construct a set with removing duplicates 2014-10-11T17:18:06Z _tca: making a set should just be list like vanila set then you can have a procedure to remove duplicates 2014-10-11T17:18:30Z _tca: the little schemer has a lot of stuff on sets like i said earlier if you want to find that part 2014-10-11T17:18:37Z daviid joined #scheme 2014-10-11T17:18:50Z lrs: Yeah I found that part 2014-10-11T17:18:56Z lrs: And tried it out, but it didnt really work 2014-10-11T17:20:06Z _tca: can you be more specific about what didn't work out? 2014-10-11T17:20:24Z lrs: http://pastebin.com/xAvd1p74 2014-10-11T17:20:47Z zacts: hi 2014-10-11T17:20:51Z vanila: hi 2014-10-11T17:20:55Z vanila: lrs, I thought you said define make-set list) 2014-10-11T17:21:21Z _tca: the parenthesis in that are mismatched lrs 2014-10-11T17:21:52Z _tca: i dont know what editor you are using but you should make sure it has all highlighting and matching and blinking etc. related to parenthesis turned on 2014-10-11T17:22:25Z _tca: also if you are using emacs or drracket you can select an entire expression and hit tab to auto-indent, that will often make it obvious where you have a mismatch 2014-10-11T17:22:56Z zacts: yeah, a good editor can be key for (scheme) programming 2014-10-11T17:27:59Z lrs: Where 2014-10-11T17:30:55Z _tca: look at the code lrs 2014-10-11T17:30:59Z _tca: why isnt it all ligned up on the left 2014-10-11T17:31:18Z _tca: after the first cond case the rest of the lines are indented an extra bit, this is because oyu never closed the first case 2014-10-11T17:32:25Z lrs: Yeah I did my own intendation 2014-10-11T17:32:36Z lrs: http://pastebin.com/xAvd1p74 2014-10-11T17:32:41Z lrs: Heres when I tried the shift thing 2014-10-11T17:32:52Z hiroakip quit (Ping timeout: 240 seconds) 2014-10-11T17:32:58Z _tca: it should look just like in the book 2014-10-11T17:33:07Z _tca: you never closed the first case like i said 2014-10-11T17:33:44Z _tca: ((null? lat) (quote ()) .......... still in this case ...... 2014-10-11T17:37:37Z BossKonaSegwaY quit (Ping timeout: 255 seconds) 2014-10-11T17:38:02Z Nizumzen quit (Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/) 2014-10-11T17:38:35Z tadni` joined #scheme 2014-10-11T17:38:45Z _tca: did you get it? 2014-10-11T17:39:06Z hiroakip joined #scheme 2014-10-11T17:40:22Z tali713 joined #scheme 2014-10-11T17:50:25Z pjdelport joined #scheme 2014-10-11T17:52:05Z lrs: _tca, Its closed at the end 2014-10-11T17:52:26Z _tca: you dont want to close it at the end, there is a paren missing earlier on, right at the first case of the cond 2014-10-11T17:52:37Z _tca: your parenthesis dont match what is in the book 2014-10-11T17:53:16Z _tca: it would look just like in the book when you indent if it was right, ((null? lat) (quote ()) <--- there is a missing paren here 2014-10-11T17:54:02Z _tca: you should probably go through more of the book than just starting there, for practice 2014-10-11T17:56:25Z lrs: Yeah, Ive looked at the chapter 2014-10-11T17:56:30Z lrs: If you mean SICP 2014-10-11T17:56:33Z BossKonaSegwaY joined #scheme 2014-10-11T17:56:34Z lrs: Or do you mean little schemer? 2014-10-11T17:56:40Z _tca: the little schemer 2014-10-11T17:56:45Z _tca: you should do it from cover to cover imo 2014-10-11T17:56:54Z lrs: No time for that 2014-10-11T17:57:03Z _tca: yea there is 2014-10-11T17:57:16Z _tca: you will waste more time getting stuck in things like this than you will going through the book 2014-10-11T17:58:16Z c107 joined #scheme 2014-10-11T18:00:03Z masm left #scheme 2014-10-11T18:03:51Z zacts: not only that, but you'll waste everyone elses time on #scheme 2014-10-11T18:04:33Z lrs: I dunno what to say 2014-10-11T18:04:37Z lrs: I dont get it 2014-10-11T18:04:44Z lrs: I dont find anything that helps me 2014-10-11T18:04:47Z lrs: Thats it 2014-10-11T18:07:26Z davexunit joined #scheme 2014-10-11T18:07:41Z zacts: ok I think Irs left. oh well.. 2014-10-11T18:07:49Z lrs: Im here 2014-10-11T18:07:58Z zacts: lrs: oh good, well.. 2014-10-11T18:08:06Z zacts: I think you may want to try the little schemer 2014-10-11T18:08:29Z zacts: and then perhaps How to Design Programs 2014-10-11T18:08:31Z lrs: Ive read the relationship chapter 2014-10-11T18:08:57Z zacts: It's been a while since I've read it, which chapter # is that? 2014-10-11T18:09:00Z lrs: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_sec_2.3.3 2014-10-11T18:09:10Z lrs: Heres the chapter that my school suggest I rea dfor the assignment 2014-10-11T18:09:21Z lrs: But I dont really find naything there either that helps me just create a set 2014-10-11T18:09:21Z zacts: Are you at Berkeley? 2014-10-11T18:09:24Z lrs: No 2014-10-11T18:09:28Z zacts: ok 2014-10-11T18:09:31Z lrs: Stockholm 2014-10-11T18:09:32Z vanila: lrs, I showed you how earlier 2014-10-11T18:09:36Z vanila: (define make-set list) 2014-10-11T18:09:39Z vanila: now you can do 2014-10-11T18:09:42Z vanila: (make-set 1 2 3) 2014-10-11T18:10:33Z zacts: lrs: do you understand how what vanila just said works? 2014-10-11T18:10:46Z lrs: Is it really that easy 2014-10-11T18:11:00Z vanila: yes 2014-10-11T18:11:15Z zacts: lrs: do you know what a lambda is? 2014-10-11T18:11:42Z lrs: Yeah 2014-10-11T18:11:45Z zacts: ok 2014-10-11T18:11:47Z lrs: Ok, well 2014-10-11T18:11:52Z lrs: I thought it was like that 2014-10-11T18:12:01Z lrs: But I thought it was to be more ocmplex 2014-10-11T18:12:12Z lrs: Also I need to remove duplicated elements too 2014-10-11T18:12:38Z zacts: lrs: I think I have a good book for you. 2014-10-11T18:13:08Z zacts: http://www.cs.unm.edu/~williams/cs357/springer-friedman.pdf 2014-10-11T18:13:20Z zacts: I'm currently getting through the book myself 2014-10-11T18:13:32Z zacts: but it has lots of examples for what you are trying to do 2014-10-11T18:13:39Z zacts: and will give you good practice 2014-10-11T18:18:18Z zacts: the chapter on sets and relations in the above book may be helpful 2014-10-11T18:21:44Z rtra quit (Ping timeout: 260 seconds) 2014-10-11T18:23:36Z rtra joined #scheme 2014-10-11T18:45:57Z ilammy joined #scheme 2014-10-11T18:46:56Z hiroakip quit (Ping timeout: 260 seconds) 2014-10-11T18:46:59Z lrs: zacts, Cool 2014-10-11T18:47:19Z zacts: =) 2014-10-11T18:47:28Z zacts: the book also covers a lot on continuations 2014-10-11T18:50:15Z robot-beethoven joined #scheme 2014-10-11T18:52:47Z zacts: b th 2014-10-11T18:54:59Z zacts: ok, is there a standard scheme primitive to find the length of a number? 2014-10-11T18:55:06Z zacts: 3521 has a length of 4 2014-10-11T18:55:10Z zacts: for example 2014-10-11T18:55:20Z vanila: no 2014-10-11T18:55:27Z zacts: Or, where may I find the base 10 log primitive? 2014-10-11T18:55:30Z Perkol joined #scheme 2014-10-11T18:55:33Z zacts: for R5RS 2014-10-11T18:55:40Z vanila: (length (string->list (number->string n))) 2014-10-11T18:56:17Z Perkol: What is the simpliest way to create an endless loop? 2014-10-11T18:56:20Z ilammy: (apply + (map (lambda (x) 1) (string->list (number->string n)))) 2014-10-11T18:56:37Z ilammy: ((call/cc call/cc) (call/cc call/cc)) 2014-10-11T18:57:31Z zacts: hm.. ok 2014-10-11T18:57:33Z vanila: lol, another way is (let loop () (loop)) 2014-10-11T18:58:50Z hiroakip joined #scheme 2014-10-11T19:01:35Z zacts: (define n-length 2014-10-11T19:01:35Z zacts: (lambda (n) 2014-10-11T19:01:35Z zacts: (length (string->list (number->string n))))) 2014-10-11T19:01:41Z zacts: oops 2014-10-11T19:01:49Z zacts: I meant to paste that into my REPL 2014-10-11T19:01:52Z Perkol: Thanks 2014-10-11T19:05:56Z ilammy: Well, you still can go a boring way with (define (n-length n) (truncate (+ 1 (/ (log n) (log 10))))) 2014-10-11T19:06:11Z vanila: that's a good way! 2014-10-11T19:06:19Z vanila: i think it's better than what I wrote 2014-10-11T19:06:20Z zacts: vanila: how can I do mod and div in scheme? 2014-10-11T19:06:25Z zacts: ilammy: ah thanks 2014-10-11T19:06:36Z zacts: ilammy's is more mathematical 2014-10-11T19:06:41Z vanila: zacts, you can use this to find out http://www.schemers.org/Documents/Standards/R5RS/HTML/ 2014-10-11T19:06:59Z vanila: Standard Procedures > Numbers 2014-10-11T19:07:08Z vanila: quotient remainder modulo 2014-10-11T19:07:36Z ilammy: (But it does not work for non-positive numbers for obvious reasons.) 2014-10-11T19:07:40Z zacts: would quotient be the same thing as mod? 2014-10-11T19:07:41Z zacts: oops 2014-10-11T19:07:44Z zacts: s/mod/div/ 2014-10-11T19:08:01Z ilammy: yep, it is 2014-10-11T19:08:29Z zacts: iok 2014-10-11T19:18:24Z zacts: I'm having the most difficult time reversing an integer, without converting to a string. 2014-10-11T19:18:27Z zacts: or to a list 2014-10-11T19:18:33Z zacts: using pure mathematics 2014-10-11T19:18:35Z zacts: but 2014-10-11T19:18:39Z zacts: don't tell me the answer 2014-10-11T19:18:46Z zacts: this is for a problem I'm working on 2014-10-11T19:18:57Z vanila: why don't you convert it to a list 2014-10-11T19:19:19Z zacts: vanila: it is autograded, and it won't allow this 2014-10-11T19:19:26Z zacts: it's for an edX class I'm taking 2014-10-11T19:19:28Z vanila: ok but, 2014-10-11T19:19:31Z vanila: you could do it by arithmetic, and use arithmetic to build up the reversed version too 2014-10-11T19:19:38Z vanila: then you can 'fuse' the two together to get a program without lists 2014-10-11T19:20:10Z vanila: the idea is to take a correct program and transform it in a way that preserves its meaning, until you get the program you want 2014-10-11T19:20:27Z _tca: n*10^length 2014-10-11T19:20:28Z zacts: ok 2014-10-11T19:20:49Z zacts: _tca: yeah that is in the formula they've provided for us. 2014-10-11T19:21:12Z zacts: I'm trying to make an iterative recursion for it. 2014-10-11T19:21:38Z zacts: (define n-reverse (lambda (n acc) ...)) 2014-10-11T19:22:28Z zacts: I must use mod and div (modulo / quotient), and I may use an n-length procedure. 2014-10-11T19:22:40Z zacts: please don't tell me the answer though 2014-10-11T19:22:54Z zacts: but hints may be welcome 2014-10-11T19:23:09Z _tca: hint is what vanila said, you can make it in seperate parts easily 2014-10-11T19:23:29Z zacts: ok 2014-10-11T19:23:43Z Nizumzen joined #scheme 2014-10-11T19:24:43Z ilammy: Well, I can't give you hint that's not an answer... 2014-10-11T19:25:33Z zacts: I think I'm close 2014-10-11T19:27:17Z ilammy: http://repl.it/1Lt <- spoiler ahead 2014-10-11T19:27:37Z offby1: ♩ ♪ ♫ spoiler ahead ... Lady in red! ♬ ♭ ♮ ♯ 2014-10-11T19:27:47Z offby1: Take my adivce -- you'd be better off dead. 2014-10-11T19:28:05Z offby1: Add Vise 2014-10-11T19:33:28Z bars0 joined #scheme 2014-10-11T19:35:05Z lrs: Im still stuck 2014-10-11T19:35:23Z zacts: ok I have it ilammy 2014-10-11T19:36:16Z vanila: lrs, what are you stuck on 2014-10-11T19:36:29Z lrs: Make-set 2014-10-11T19:36:39Z vanila: (define make-set list) 2014-10-11T19:36:41Z vanila: there 2014-10-11T19:37:21Z lrs: Yeah 2014-10-11T19:37:40Z lrs: But I need to make it so that it replace duplicates 2014-10-11T19:37:57Z lrs: and (sort l >) 2014-10-11T19:38:13Z zacts: ilammy: http://paste.lisp.org/display/144006 2014-10-11T19:38:43Z ilammy: lrs, check for duplicates when adding stuff to the set to make sure that the elements are unique 2014-10-11T19:39:04Z ilammy: O(n) add but who cares 2014-10-11T19:39:17Z vanila: lrs, Well then, (define (make-set . l) (sort (replace-duplicates l) >)) 2014-10-11T19:39:38Z lrs: Why . l 2014-10-11T19:39:46Z vanila: that lets you pass in any number of parameters 2014-10-11T19:39:59Z vanila: so (make-set 1 2 3) will work as well as (make-set 'a 'b 'c 'd 'e 'f) 2014-10-11T19:40:05Z lrs: So 2014-10-11T19:40:06Z lrs: + 2014-10-11T19:40:09Z lrs: 2 2014-10-11T19:40:09Z lrs: l 2014-10-11T19:40:09Z lrs: k 2014-10-11T19:40:10Z lrs: .. 2014-10-11T19:40:11Z lrs: etc 2014-10-11T19:40:55Z ilammy: (lambda lambda lambda) - a fancy way to write list \o/ 2014-10-11T19:41:00Z vanila: lol 2014-10-11T19:41:05Z vanila: that is crazy 2014-10-11T19:41:40Z lrs: (lambda x x) 2014-10-11T19:41:46Z _tca: nice lrs :) 2014-10-11T19:46:14Z mutley89 joined #scheme 2014-10-11T19:46:56Z Gyps joined #scheme 2014-10-11T19:47:10Z romcgb joined #scheme 2014-10-11T19:49:52Z acarrico quit (Ping timeout: 245 seconds) 2014-10-11T19:54:36Z rtra quit (Ping timeout: 260 seconds) 2014-10-11T19:57:15Z rtra joined #scheme 2014-10-11T19:59:41Z oleo__ joined #scheme 2014-10-11T19:59:56Z oleo is now known as Guest72639 2014-10-11T20:01:56Z Guest72639 quit (Ping timeout: 250 seconds) 2014-10-11T20:04:50Z acarrico joined #scheme 2014-10-11T20:05:28Z Perkol quit (Remote host closed the connection) 2014-10-11T20:05:36Z oleo__ quit (Quit: Verlassend) 2014-10-11T20:06:03Z oleo__ joined #scheme 2014-10-11T20:06:15Z oleo__ quit (Read error: Connection reset by peer) 2014-10-11T20:08:14Z oleo joined #scheme 2014-10-11T20:16:14Z romcgb quit (Ping timeout: 250 seconds) 2014-10-11T20:30:01Z ivanshmakov quit (Read error: Connection reset by peer) 2014-10-11T20:38:56Z ivanshmakov joined #scheme 2014-10-11T20:52:52Z kongtomorrow joined #scheme 2014-10-11T21:00:26Z kongtomorrow quit 2014-10-11T21:04:08Z hiroakip quit (Ping timeout: 260 seconds) 2014-10-11T21:19:22Z jeapostrophe quit (Ping timeout: 245 seconds) 2014-10-11T21:29:36Z gravicappa quit (Ping timeout: 246 seconds) 2014-10-11T21:32:01Z tadni` quit (Remote host closed the connection) 2014-10-11T21:36:19Z Adamm1 joined #scheme 2014-10-11T21:36:37Z Adamm1: Hi Guys 2014-10-11T21:36:56Z _tca: hi 2014-10-11T21:37:13Z Adamm1: Am a junior ruby developer looking to improve as a programmer, so I recently came across the SICP book 2014-10-11T21:37:45Z Adamm1: a lot of people say that working through this book helped them become better programmers 2014-10-11T21:38:25Z Adamm1: so I started working through it this week and so far its been enjoyable but challenging. 2014-10-11T21:39:08Z Adamm1: I was wondering if I could use this channel to ask questions 2014-10-11T21:39:12Z _tca: yea you can 2014-10-11T21:40:26Z bokr joined #scheme 2014-10-11T21:42:58Z aranhoide joined #scheme 2014-10-11T21:47:19Z Adamm1: Am a bit confused on what normal order evaluation is, the author says 'An alternative evaluation model would not evaluate the operands until their values were needed' 2014-10-11T21:47:31Z Adamm1: What does that mean 2014-10-11T21:48:03Z Adamm1: does that mean the expressions that are the operands are only substituted for the parameters 2014-10-11T21:48:45Z Adamm1: and evaluated when everything has been simplified 2014-10-11T21:55:16Z Nizumzen quit (Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/) 2014-10-11T22:02:35Z azathoth99 joined #scheme 2014-10-11T22:04:17Z bars0 quit (Quit: leaving) 2014-10-11T22:04:26Z pjb: Adamm1: if we don't evaluate the operands until their values are needed, that's called lazy evaluation, and that's a good thing in purely functional programming. But when you work with side effects (I/O), this may be a problem. 2014-10-11T22:05:49Z pjb: Adamm1: lazy evaluation lets you write: (define (if test then else) (cond ((test then) (#t else)))) (if #f (nuke-them-all) (display 'hello)) ; nuke-them-all is not called, because its value is never needed. 2014-10-11T22:08:09Z Adamm1: So lazy evaluation lets you skip evaluating certain code until its needed. 2014-10-11T22:08:15Z _tca: yea 2014-10-11T22:09:53Z Adamm1: Thanks pjb and _tca 2014-10-11T22:11:56Z _tca: Adamm1: if you have (define (foo a) (+ a 1)) .. in applicative (foo (+ 1 1)) -> (foo 2); a naive call-by-need would look like: (foo (lambda () (+ 1 1))) notice the lambda wrapper to delay.. then foo has to get evaluate it like (define (foo a) (+ (a) 1)) 2014-10-11T22:12:55Z pjb: Adamm1: in scheme we don't have lazy evaluation, so we cannot write if like this. We must write a macro/syntax. We can write: (define (if* test then else) (cond (test (then)) (#f (else)))) and (if* #f (lambda () (nuke-them-all)) (lambda () (display 'hello))). (define-syntax if (syntax-rules () ((if test then else) ((if* test (lambda () (then)) (lambda () (else))))))) 2014-10-11T22:13:19Z azathoth99: is recursive stuff same as loop in tcl? 2014-10-11T22:13:47Z pjb: There's an equivalence. 2014-10-11T22:14:07Z pjb: But recursion can do more than loops. recursion = loop+stack 2014-10-11T22:14:40Z pjb: Only simple terminal recursion is strictly equivalent to loops. 2014-10-11T22:15:36Z ilammy: pjb, _tca, Adam1: actually, Scheme does have things for lazy evaluations: delay and force 2014-10-11T22:15:47Z azathoth99: why are continuations importaant? if 1 os thread is involved, it means the program cant spean all avaialble cpu right? even if 1 cpu can have many microthreaqds? 2014-10-11T22:16:11Z _tca: ilammy: his question was about the difference between the two models 2014-10-11T22:16:34Z ilammy: it is somewhat important to understand the concept of continuations from theoretical point of view 2014-10-11T22:17:08Z ilammy: but it's not that important for writing useful programs 2014-10-11T22:17:26Z _tca: its gavino if you two haven't realized 2014-10-11T22:17:48Z _tca: tcl too obvious 2014-10-11T22:21:09Z vanila: azathoth99, that continuations let you do cooperative multithreading is just one example of their power 2014-10-11T22:21:24Z Adamm1: _tca and ilammy Yeah my question was more about the difference between applicative order evaluation vs normal order evaluation 2014-10-11T22:21:26Z azathoth99: hm 2014-10-11T22:21:40Z azathoth99: so how can I best use a say 64 cpu box 2014-10-11T22:21:53Z azathoth99: if my scheme program is stuk on 1 cpu? 2014-10-11T22:22:01Z vanila: azathoth99, The really important thing about continuations is as a concept in understanding programs 2014-10-11T22:22:14Z azathoth99: is there a way to have 63 slave worker sprocesses talk to 1 master procss on cpu 64? 2014-10-11T22:22:42Z vanila: azathoth99, I think that Sussmans Propagators will give us a way to do that in the future 2014-10-11T22:23:05Z ilammy: Adamm1, then I'd recommend some book on lambda calculus if you're really interested 2014-10-11T22:23:07Z azathoth99: I so far think scheme is way way ahead of tcl or other stuff I have seen in the ability to write a program that seems to make sense, but I worry my program is handstrung performacen wise 2014-10-11T22:23:37Z azathoth99: after I have nice abstractions and can read the program, it has to run 2014-10-11T22:23:41Z azathoth99: and run fast 2014-10-11T22:24:05Z ilammy: How much fast? 2014-10-11T22:24:45Z vanila: azathoth99, tcl beats scheme at GUIs! 2014-10-11T22:25:01Z vanila: and it has some crazy homoiconic stuff going on that even scheme doesn't really do 2014-10-11T22:25:16Z vanila: there's no competition, they're both great 2014-10-11T22:26:02Z _tca: azathoth99: i know there is some java implementations of scheme that give you access to it's multithreading capabilities, you can also do distributred programming through a serialization library like prevayler to send continuations around 2014-10-11T22:27:19Z azathoth99: I wont touch jvm 2014-10-11T22:27:43Z azathoth99: say uhave a web server 2014-10-11T22:28:04Z azathoth99: is the strategy to fork 1 process per user, and then have that process handle all user requests? 2014-10-11T22:28:18Z azathoth99: and let the os spread the processes among the cpus? 2014-10-11T22:28:27Z azathoth99: sounds strikingly familiar to cgi 2014-10-11T22:30:41Z _tca: azathoth99: you can fork a continuation without forking the entire process and run it on another core if the implementation supports it , otherwise you can serialize it and send it to another process 2014-10-11T22:32:00Z _tca: azathoth99: a good example of this is the industrial quality seaside web framework for smalltalk 2014-10-11T22:37:15Z ee_cc_ joined #scheme 2014-10-11T22:37:54Z azathoth99: well say chicken scheme or another C not java based scheme 2014-10-11T22:38:01Z azathoth99: I suppose racket does 2014-10-11T22:38:05Z azathoth99: but is racket scheme? 2014-10-11T22:38:22Z azathoth99: I am curious how well say awful by the chicken folks performs 2014-10-11T22:38:28Z azathoth99: when 100s of requests come in 2014-10-11T22:38:34Z azathoth99: I wonde rif its liek cgi 2014-10-11T22:38:40Z azathoth99: forking 1 proc per user to handle it 2014-10-11T22:42:29Z tadni` joined #scheme 2014-10-11T22:48:44Z es joined #scheme 2014-10-11T22:48:53Z azathoth99: dutch! 2014-10-11T22:50:40Z azathoth99 left #scheme 2014-10-11T22:53:37Z ilammy quit (Ping timeout: 246 seconds) 2014-10-11T22:55:17Z vanila quit (Ping timeout: 245 seconds) 2014-10-11T22:58:36Z Adamm1 quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) 2014-10-11T22:59:56Z vanila joined #scheme 2014-10-11T23:06:27Z effy quit (Read error: Connection reset by peer) 2014-10-11T23:07:44Z effy joined #scheme 2014-10-11T23:33:46Z vanila quit (Quit: Leaving) 2014-10-11T23:46:37Z tobik quit (Ping timeout: 260 seconds) 2014-10-11T23:47:19Z Gyps quit (Quit: Gyps) 2014-10-11T23:48:20Z tobik joined #scheme 2014-10-11T23:50:37Z Gyps joined #scheme 2014-10-11T23:51:03Z ee_cc_ quit (Quit: ee_cc_) 2014-10-11T23:52:59Z zacts: I'm considering making my todo lists in s-expr 2014-10-11T23:56:34Z c107 quit (Ping timeout: 258 seconds) 2014-10-11T23:56:45Z vinleod joined #scheme