
: 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

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

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

ah

that’s it

oops

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

even though i have +
as the function already?

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

which is basically what notjack said already

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

ahh gotcha

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

quoting?

'(1 2 3)

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.


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

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

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

+
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)

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.

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

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

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

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.

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

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

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.

we are using '
for parsing things for the interpreter

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.

that is a good explanation lexi.lambda, thank you

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

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

there’s also the backquote

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

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

which turns it in s-expression i think

What @lexi.lambda said.

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

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

realizes typing quasiquote in Slack is going to be complicated

oh god

Just use the longhand, lol.

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

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

Right.

Except that both quasiquote
and unquote
have shorthand forms.

quosiquote
is ``` ?

shit

Yup

Right, and unquote is ,
.

; quasiquote is `, unquote is ,
`(1 ,(+ 1 1) 3) ;=> '(1 2 3)

:smile:

yay!

we need rudybot in Slack :wink:

yes, yes we do

rudybot?

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

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

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

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

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

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

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

rudybot also links to docs and things of equal usefulness

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

:O we need that

or i need that

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

Of course, that means it’ll never happen.

That’d be a fun one

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

cky: What a bad Racketeer! :wink:

Lol.

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

the package system is f*cked

runs

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.

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”

like I said

It shouldn’t be too difficult to add at least

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

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

cky: I saw that coming

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

cky: OP is incompetent :simple_smile:

:wink:

Stack Overflow is a special kind of hell

OP is giving me a bad name

@lexi.lambda: not yet

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

luckily my chat handle gives me plausible deniability

Lulz.

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