ebzzry has quit [Read error: Connection reset by peer]
nullman has quit [Ping timeout: 246 seconds]
nullman has joined #racket
casaca has quit [Ping timeout: 265 seconds]
casaca has joined #racket
casaca has quit [Ping timeout: 240 seconds]
casaca has joined #racket
mzan has joined #racket
jsgrant_ has joined #racket
<jsgrant_>
Is it a goal of Racket2 / Rhombus to be homoiconic; Or more-so just a Lisp-like macro system?
endformationage has joined #racket
pera has quit [Ping timeout: 276 seconds]
orivej has quit [Ping timeout: 268 seconds]
pera has joined #racket
notzmv has joined #racket
pera has quit [Ping timeout: 276 seconds]
pera has joined #racket
mzan has quit [Quit: Leaving]
<erkin>
I think it would look a lot like Rebol then.
pera has quit [Ping timeout: 265 seconds]
notzmv has quit [Remote host closed the connection]
jao has quit [Remote host closed the connection]
<erkin>
Is there a way to force Racket's CLI REPL to read UTF-8?
<erkin>
It defaults to Windows-1252 and produces mojibake when I try to input Unicode characters.
<erkin>
locale-string-encoding parameter is "UTF-8"
<rs>
Running 'racket -f foo.rkt -i '(hello)' runs fine, but if I run that inside of a watch i get an error 'sh: 1: Syntax error: Unterminated quoted string'. Why is this happening?
<erkin>
Watch?
<rs>
watch -n 3 racket -f foo.rkt -i '(hello)'
aidalgol has joined #racket
<erkin>
rs: You need to escape the parentheses.
Trieste has quit [Ping timeout: 240 seconds]
<erkin>
You probably want -e instead of -i there.
<erkin>
% watch -n 3 racket -f foo.rkt -e '"(hello)"' should do the trick.
Trieste has joined #racket
<rs>
erkin: right, I'm using an -e, I incorrectly stated above I was using an -i. I've tried escaping it and now getting an error: expected a ')' to close a '('. Here is the code I'm trying to use the watch with. https://termbin.com/t3kc
<rs>
The code may not work or is ugly but the ending paren is there.
<rs>
I'm still getting the exact same error inside of watch.
<erkin>
That's strange. What shell are you using?
<rs>
bash
<rs>
Oh, wait. When I remove the escapes it works.
<erkin>
I should've said quote instead of escape in the first place, sorry.
<rs>
And apparantly the order of the quotes '"(fucntion)"' is irrelevant and can be in either order in this example.
<rs>
It works in this order as well "'(function)'"
<rs>
The importance appears to be that it wants double quotes somewhere.
<rs>
I'm learning: Could you explain why you would use cons in the not condition instead of using just a list as my failed code uses?
<erkin>
The problem with the code wasn't actually with list/cons, but 'not' was on its own.
<erkin>
In addition, car and cdr operations shouldn't be used on numbers.
<erkin>
When you're consing two things, you're effectively making the first one point to the second one. That's how linked lists work. By recursively consing and going down, you're attaching a new node to the head of the list at each iteration.
<erkin>
(list 5) is (cons 5 (list)), (list 4 5) is (cons 4 (list 5)), (list 3 4 5) is (cons 3 (list 4 5)) and so on
<erkin>
(Note that the last node must be nil.)
<erkin>
Try replacing that cons with list and you'll see that instead of '(1 2 3 4) it forms '(1 (2 (3 (4 (5))))).
<erkin>
Because (list 1 2) is effectively (cons 1 (cons 2 '()))
<erkin>
rs: Do you follow?
<rs>
Yes. Although I haven't read enough apparantly to understand that cons was like a linked list. Yes I've seen that very output '(1 (2 ... ))))), not understanding why. How you explained it makes perfect sense.
<erkin>
:-)
<erkin>
Just know that cons makes a car and a cdr.
<erkin>
You can make a pair if the cdr isn't a list. (cons 1 2), for instance.
<rs>
That also makes sense. That last statement will take a few moments to sink in. :|
<erkin>
:-)
<rs>
Can you elaborate on this: (list 5) returns '(5), (cons 1 (list 5)) returns only the '(1 5) not '(1 (5)) ? Is that where you said '..cons makes a car and a cdr'? cdr is removing the parens on output?
<rs>
.. For cons?
<erkin>
Sorry, I was afk.
<erkin>
You see, (list 5) is already (cons 5 '()).
<erkin>
When you cons 1 on that, it becomes 1 -> 5 -> nil.
<erkin>
That's a proper linked list.
<rs>
Right.
<erkin>
In this case, the car is 1 and the cdr is 5 -> nil
<erkin>
cdr of 5 -> nil would be nil.
teardown has quit [Quit: leaving]
teardown has joined #racket
libertyprime has quit [Ping timeout: 268 seconds]
<rs>
So car is being performed on each node? After each next node is cdr of the first node? I'm I thinking correctly?
<rs>
Or rather cdr or what is left after the first node.
jao has joined #racket
<erkin>
Think of it like a chain of conses.
<erkin>
(cons 1 (cons 2 (cons 3 (cons 4 '()))))
teardown has quit [Client Quit]
teardown has joined #racket
<erkin>
That's '(1 2 3 4)
<erkin>
car is 1, cdr is (cons 2 (cons 3 (cons 4 '()))), which is '(2 3 4)
<erkin>
The first element of the cons is the car, the second one is the cdr.
pera has joined #racket
<erkin>
By taking the cdr over and over, you're traversing the list that keeps shrinking (from your point of view).
<erkin>
It's popular to think of it like "car is the first, cdr is the rest of the list" but it's actually more accurate to think of them like the two portions of a cons cell.
<rs>
Got it. Geez, why aren't you my instructor! I've learnt more in a few minutes than I have in a few weeks.
<erkin>
Haha, thank you
<erkin>
Yeah, for some reason this fundamental concept not very well explained in most places.
<erkin>
is not*
<erkin>
The cdr doesn't have to be a list either. (cons 1 2) gives you a pair, represented as '(1 . 2)
<erkin>
car is 1, cdr is 2, obviously enough.
<erkin>
Pairs are useful when you need your data associated with values.
<rs>
I think there's this expectation or idea that everyone understands the same way. And they consequently think they are teachng it perfectly.
<rs>
Yes, I was noticing that in the documentation.
<erkin>
For instance, consider a list of pairs: '((cat . meow) (dog . bark) (bird . chirp)) The car would be '(cat . meow), whose car and cdr would be 'cat and 'meow respectively.
<erkin>
I agree, but I suppose that problem is inherent to the education system in general.
<rs>
Right. And you would want to treat them not in pairs, how?
<erkin>
How do you mean?
<rs>
I wholeheartdly agree.
<rs>
A list such as (meow, woof, bark) not in pairs ((meow . woof) bark)
<erkin>
You mean like taking the cdrs of each pair?
<rs>
Well you mentioned that cons is the best way to handle numbers
<erkin>
Oh it was just an example.
<rs>
I assume values you meant numbers.
<erkin>
It can be any value!
<rs>
Or referred to.
<erkin>
In this case, I'm using symbols.
<erkin>
The 'cat symbol is associated with 'meow.
<erkin>
This form is called an association list (called alist for short). It's the logical conclusion of the cons system being used for key/value pairs.
<erkin>
To get what a dog says, you traverse through the list, checking the car of each pair and getting the cdr when you come across the symbol 'dog.
jao has quit [Remote host closed the connection]
<rs>
Got it.
<erkin>
Just a tidbit of info: You can omit the final nil in your list and make the last node a pair. Such as (cons 1 (cons 2 3)), instead of (cons 1 (cons 2 (cons 3 '()))). This is called an *improper* list, represented as '(1 2 . 3). It's not very useful.
<erkin>
Most functions operating on lists expect the last value to be nil, so that they know when to stop. This means you can't use improper lists with them.
<erkin>
I have no idea what anyone could use an improper list for, but newbies often (accidentally) come across one and get confused.
Guest48365 has joined #racket
Trieste has quit [Ping timeout: 268 seconds]
Guest48365 has quit [Remote host closed the connection]
jao- has joined #racket
Trieste has joined #racket
<rs>
That is very useful.
johnjay has quit [Ping timeout: 240 seconds]
libertyprime has joined #racket
Trieste has quit [Ping timeout: 240 seconds]
johnjay has joined #racket
Trieste has joined #racket
pera has quit [Ping timeout: 268 seconds]
Arcaelyx has quit [Quit: Arcaelyx]
lavaflow has quit [Ping timeout: 245 seconds]
Fernando-Basso has quit [Quit: Leaving]
ebzzry has joined #racket
teardown has quit [Quit: leaving]
<jcowan>
erkin: Lazy lists have a generator in the cdr of the last pair, so when you cdr down there, you call the generator to get the next value and splice it on the end of the list.
<jcowan>
Another application is an a-list with a hashtable in the last cdr holding all the basic things, and then pairs just contain local associations.
<erkin>
That generator idea is very clever. I like how it can be transparently passed to ordinary list procedures.
jsgrant_ has quit [Remote host closed the connection]