ryoia
2015-9-7 23:31:31

: i’m trying the map2 function in plai-typed, which is: (('a 'b -> 'c) (listof 'a) (listof 'b) -> (listof 'c)), and i have this example: (map2 + (list (2 3 4)) (list (3 4 5))). but i keep getting this error typecheck failed: number vs (number number -> '_a) in: 2


notjack
2015-9-7 23:32:14

@ryoia: (list 1 2 3) constructs a list with three items


notjack
2015-9-7 23:32:30

(list (1 2 3)) does not do that and should error


notjack
2015-9-7 23:32:40

ah


ryoia
2015-9-7 23:32:46

that’s it


ryoia
2015-9-7 23:32:49

oops


notjack
2015-9-7 23:32:55

the error is saying it expected the 2 to be a function taking two numbers


ryoia
2015-9-7 23:33:16

even though i have + as the function already?


lexi.lambda
2015-9-7 23:33:35

(2 3 4) will try and apply 2 as a function


lexi.lambda
2015-9-7 23:33:45

which is basically what notjack said already


notjack
2015-9-7 23:33:46

The + is fine. It’s the (2 3 4) expression. It expects the first value in the list to be a function, but it’s 2


ryoia
2015-9-7 23:34:35

ahh gotcha


notjack
2015-9-7 23:34:59

whenever you have (x y z) in normal circumstances, Racket expects x to be a function and will apply it. When you want a list of data use either (list x y z) or quoting


ryoia
2015-9-7 23:36:06

quoting?


lexi.lambda
2015-9-7 23:37:06

'(1 2 3)


notjack
2015-9-7 23:37:40

that would be the “abnormal” circumstances. (x y z) is an expression where x, y, and z are evaluated, then x is applied as a function with arguments y and z. But if you have '(x y z), then racket does no evaluation whatsoever and produces a list of the three symbols x y and z.



ryoia
2015-9-7 23:39:09

ah got it. sorry i was confused why to quote '(1 2 3)


dann
2015-9-7 23:39:55

yeah, it’s confusing, but (list 1 2 3) is the same as '(1 2 3)


dann
2015-9-7 23:40:15

(or I found that somehow confusing, at least, when I was first learning scheme)


notjack
2015-9-7 23:40:58

+ is the addition function. '+ is just the addition symbol, it has no meaning on it’s own and no relation to the function. Symbols are just names. You can’t evaluate them as variables. Quoting numbers produces just the numbers, i.e. '1 is the same as 1. Quoting expressions produces a list of the quoted items, i.e. (+ 1 2) is evaluated turning + into the addition function and applying it to 1 and 2 to get 3, but '(+ 1 2) is a list of three quoted items, (list '+ '1 '2), the quoted plus produces the plus symbol, and the quoted 1 and 2 produce just the numbers 1 and 2, giving a final result of (list '+ 1 2)


lexi.lambda
2015-9-7 23:41:30

I think the especially tricky bit is that '(a b c) is not the same as (list a b c). In order to really grok (quasi)quoting, it’s helpful to understand what the reader is and how it works.


dann
2015-9-7 23:41:49

(Yeah, that was the part I found confusing ^_^)


notjack
2015-9-7 23:41:52

Yeah. I find it easier to think of '(a b c) as (list 'a 'b 'c)


ryoia
2015-9-7 23:42:22

mm yeah '(a b c) is like (list 'a 'b 'c) makes sense. i’ll start think about it like that for now


lexi.lambda
2015-9-7 23:42:56

I don’t like that explanation because it’s not really accurate about what’s going on underneath… but it is probably a good way to learn it, so whatever.


ryoia
2015-9-7 23:44:35

i think i got what the ' does to the numbers/functions/etc, it just won’t evaluate whatever is behind it


cky
2015-9-7 23:45:07

I agree with @lexi.lambda, it’s better not to deal with quoted list datums until much further down the line. :simple_smile:


notjack
2015-9-7 23:46:01

Yeah most of the time you should probably just use list and forget about quoting unless you’re only quoting symbols, like using 'up 'down 'right and 'left to represent directions or something.


ryoia
2015-9-7 23:46:46

we are using ' for parsing things for the interpreter


lexi.lambda
2015-9-7 23:47:05

The “real” way to explain quoting: all Scheme code is actually made up of lists. So when you write (+ 1 2 3), the code itself is actually the linked list containing the symbol + and the datums 1, 2, and 3. Normally, Scheme evaluates lists in code by taking the first element of each list, evaluating it as a function, and applying it to the remaining elements of the list. Quoting just “turns off” the evaluation, so it just returns the list as produced by the reader.


ryoia
2015-9-7 23:48:00

that is a good explanation lexi.lambda, thank you


notjack
2015-9-7 23:48:21

and then there’s syntax objects which make things even more complicated.


cky
2015-9-7 23:48:26

Right, it returns the datum itself rather than evaluating it.


ryoia
2015-9-7 23:48:38

there’s also the backquote


lexi.lambda
2015-9-7 23:48:42

Yeah, syntax objects are a whole new bit of fun. But those are an advanced topic. :simple_smile:


cky
2015-9-7 23:48:46

@notjack: You don’t have to deal with syntax objects unless you’re writing macros.


ryoia
2015-9-7 23:48:47

which turns it in s-expression i think


cky
2015-9-7 23:48:49

What @lexi.lambda said.


cky
2015-9-7 23:49:08

@ryoia: No, quasiquote is something else, it’s like quote but allows selected elements to be unquoted.


lexi.lambda
2015-9-7 23:49:08

The backquote is just quasiquote, which just lets you “turn on” the evaluation again in the middle of the quoted expression.


lexi.lambda
2015-9-7 23:49:36

realizes typing quasiquote in Slack is going to be complicated


notjack
2015-9-7 23:49:50

oh god


cky
2015-9-7 23:49:59

Just use the longhand, lol.


cky
2015-9-7 23:50:24

(quasiquote (= (+ 1 2) (unquote (+ 1 2)))) == (= (+ 1 2) 3)


ryoia
2015-9-7 23:51:05

ohh so it enabled evaluating for (unquote (+ 1 2)) again


cky
2015-9-7 23:51:22

Right.


cky
2015-9-7 23:51:34

Except that both quasiquote and unquote have shorthand forms.


ryoia
2015-9-7 23:51:47

quosiquote is ``` ?


ryoia
2015-9-7 23:51:50

shit


notjack
2015-9-7 23:51:50

Yup


cky
2015-9-7 23:51:57

Right, and unquote is ,.


lexi.lambda
2015-9-7 23:52:08
; quasiquote is `, unquote is ,
`(1 ,(+ 1 1) 3) ;=> '(1 2 3)

cky
2015-9-7 23:52:25

:smile:


ryoia
2015-9-7 23:52:32

yay!


lexi.lambda
2015-9-7 23:52:38

we need rudybot in Slack :wink:


notjack
2015-9-7 23:52:47

yes, yes we do


ryoia
2015-9-7 23:52:58

rudybot?


notjack
2015-9-7 23:53:20

Or to get the regular rudybot to recognize instructions of the form “blah …. … … @rudybot instruction …”


cky
2015-9-7 23:53:35

But the results wouldn’t be properly quoted, so.


lexi.lambda
2015-9-7 23:54:28

it’d probably be best to integrate it with slackbot so it’s available everywhere


notjack
2015-9-7 23:55:12

By the way @lexi.lambda, how goes #lang envy?


lexi.lambda
2015-9-7 23:55:13

ryoia: rudybot is an IRC bot that evaluates Racket code examples inline


lexi.lambda
2015-9-7 23:55:27

notjack: I haven’t had the time to work on it lately :stuck_out_tongue:


ryoia
2015-9-7 23:55:28

oh nice, that’d be super helpful here :smile:


lexi.lambda
2015-9-7 23:55:48

rudybot also links to docs and things of equal usefulness


notjack
2015-9-7 23:56:04

and some not-so-useful things that are more for entertainment


ryoia
2015-9-7 23:56:06

:O we need that


ryoia
2015-9-7 23:56:09

or i need that


cky
2015-9-7 23:57:49

In my copious free time, I had meant to work on #lang golfscript /cc @notjack @lexi.lambda


cky
2015-9-7 23:57:58

Of course, that means it’ll never happen.


notjack
2015-9-7 23:58:07

That’d be a fun one


lexi.lambda
2015-9-7 23:58:10

I’ve tried to get into http://PCG.SE\|PCG.SE, but I just hate the concept. :(


lexi.lambda
2015-9-7 23:59:40

cky: What a bad Racketeer! :wink:


cky
2015-9-8 00:00:58

Lol.


notjack
2015-9-8 00:02:31

Weird. I think the package server stores ring information not with a (ring . n) hash entry, but with (ring:1 . #t) and the absence of ring:0 and ring:2 keys


lexi.lambda
2015-9-8 00:03:50

the package system is f*cked


lexi.lambda
2015-9-8 00:03:54

runs


notjack
2015-9-8 00:04:33

I’m quite fine with the packageN naming idea, I just want something for minor version support. And a lot more docs and guidance about managing and publishing packages.


notjack
2015-9-8 00:07:35

I find it absurd that if I say I need version 2.3 of package foo, and the package source for foo points to 623.12, the package catalog goes “sure this is equivalent”


lexi.lambda
2015-9-8 00:08:57

like I said


notjack
2015-9-8 00:09:33

It shouldn’t be too difficult to add at least


cky
2015-9-8 00:10:00

@lexi.lambda: OP needs to learn how to use lambda. :’(


notjack
2015-9-8 00:10:03

instead of storing a package name’s source, store a hash mapping versions to sources for that package


lexi.lambda
2015-9-8 00:10:45

cky: I saw that coming


lexi.lambda
2015-9-8 00:10:57

notjack: yes, but the package system doesn’t support that, which is why it is broken


lexi.lambda
2015-9-8 00:11:14

cky: OP is incompetent :simple_smile:


cky
2015-9-8 00:11:20

:wink:


lexi.lambda
2015-9-8 00:11:46

Stack Overflow is a special kind of hell


notjack
2015-9-8 00:11:58

OP is giving me a bad name


notjack
2015-9-8 00:12:25

@lexi.lambda: not yet


lexi.lambda
2015-9-8 00:12:42

notjack: edit the question into a shining bastion of Stack Overflow quality to defend your dignity


notjack
2015-9-8 00:13:12

luckily my chat handle gives me plausible deniability


cky
2015-9-8 00:13:19

Lulz.


ryoia
2015-9-8 00:18:05

thanks all for helping me understanding this better! :smile: