
I was particularly confused about first
and rest
vs. car
and cdr

For example, (cons '() 3)
is apparently not a list, and first
and rest
won’t work on it

but car
and cdr
work just fine

That is because car and cdr operate on a low level, they see a list as a linked list of pairs

But to me, the structure looks all very list-like

cons
always return a pair, (cons '(), 3)
will return ('() . 3)
which is a pair

first
and rest
operates on a more abstract level, they expect their parameters to be lists

the reason cons
, car
, and cdr
work fine on a list is because they sees a list just as linked pairs

So a list of size 2 is different from a pair?

(list '() 3)
versus (cons '() 3)

yes, they are different

why don’t you write out (list '() 3)
using pair notation like I did in yesterday’s message?

and compare to what (cons '() 3)
looks like in pair notation

Racket spits it back out without the period

But conceptually I thouht they are the same

I thought my (list '() 3)
is built out of a pair

so I thought the smallest list and a pair should be identical

there is more than one pair involved in (list '() 3)

written out in pair notation, (list '() 3)
would look like ('() . (3. '()))

(cons '() 3)
in pair notation would look like ('() . 3)

Oh I see you’re saying there’s an implicit hidden '()

as you can see, (list '() 3)
and (cons '() 3)
look nothing like each other when viewed as pairs

My Dr. Racket doesn’t give out those periods

I mean, it normally does, but not for list

the Racket printer hides the underlying pair nature of a list from you by printing as (’() 3) without any periods

Is there a Racket tool to more easily visualize the linked pairs underneath?

I think so yes, there’s an option to configure the Racket printer

let me see

not able to find it at the moment, maybe others will be able to point it out for us

Ah well on your hint I dived into 1.4.5
of the Reader docs

but it appears my Dr Racket is on maximum verbosity

@slack1 if you’re new to lists and pairs, you might find the “Beginning Student Language” helpful, and trying things out there

if you’d like to practice in your DrRacket, try (cons 'a 'b)
and (cons 'a '())
and compare the two results

where you will only be able to use cons
to construct lists

Sorry for the noob question but what is the difference between the top window in DR Racket and the bottom/REPL one?
In particular why can’t I evaluate this form (include-book "j-bob-lang" :dir :teachpacks)
in the bottom window but can in the top?
(I’m trying to go through the little prover)

(so have installed Dracula/ACL2)

@rick.moynihan what does DrRacket say the Language is?

ACL2


@samth: I use emacs/clojure mainly - so am familiar with having a file/buffer and a repl. I’m assuming that’s going on here, but would’ve expected the include-book
form to evaluate the same in both places. So mainly curious about that aspect.

@rick.moynihan It looks like you can do include-book
in the top but not the bottom?

yes

oh that’s strange doing it now it works

So I assume that the ACL2 language only allows new books in the definitions area, but I don’t know why

not sure what has changed

i feel as though i’ve seen something, even recently but can’t find it… has someone done a language usage survey — like that of http://taylor.fausak.me/2017/11/15/2017-state-of-haskell-survey-results/ before?

(obviously for racket)

@apg no, I don’t think we’ve done anything like that

@samth ah. ok.

for some reason I though I remembered something like that happening recently.. obviously I’m wrong. :slightly_smiling_face:

The survey questions from the Haskell survey linked above are actually quite interesting and I think mostly applicable to Racket… aside maybe from the different packages servers and tools, of course.

I’m tempted to try to put something like this together for racket — any interest?

@apg I think something like that would be cool

yeah, me too. if anyone is interested in helping, let me know. I’ll start thinking about how to pull it off.

You mean a State of Racket survey? That would be interesting

Can anyone point me in the right direction on making a simple http get request in Racket?

The docs for the http client are a little terse ~_~

@slack1 #lang racket
(require net/url)
(port->string (get-pure-port (string->url "<https://google.com/>")))

@apg: Maybe you were thinking of the recent RacketCon survey?

Also, seconding the “this would be great” comment!

@stamourv it wasn’t the racketcon survey. I must have dreamed about a results post, because I swear Ben wrote it. Apparently, I dream about racket surveys? idk.