
I have a string that I’d like to split where the sep is a \0 character. (string-split “1\02\03\0” "\0" ) doesn’t give me what I expected (“1” “2” “3” ). Thanks for the fix.

The string "1\02\03\0"
might not be what you expected, maybe you meant "1\0002\0003\000"
, or equivalently "1\x002\x003\x00"
The docs section Reading Strings says this about the \<digit>
forms: > A longer form takes precedence over a shorter form
Which means that when \0
is followed by another digit such as 2
, it’s interpreted as \(02)
not (\0)2

This is a series of ints, doubles, chars and strings sent over a TCP connection by the Interactive Brokers TWS API. The separator is ’\0’ between every one of these pieces of information. So I’ll have to read char by char, create my own split function.

Wait, when you print the string, does it show "1\u00002\u00003\u0000"
, or does it show "1\\02\\03\\0"
? One backslash or two?

If it’s two backslashes the relevant example is (string-split "1\\02\\03\\0" "\\0")

Or if its one backslash, then the relevant example is (string-split "1\0002\0003\000" "\000")

Is the separator a null character, or is it a backslash character followed by a 0 character?

’\0’ is how I see the separator being expressed in other reference language implementations of the API. It’s the NUL character.

Same character used in the C language to terminate a string.

Okay. The way you represent the NUL character in the reference language is \0
, but in Racket it needs to represented by \000
or \x00
etc.

(string-split “1\0002\0003\000” "\000" ) works. I’ll try it out on the real data coming across the net connection later today. Thanks!

> (angle 0)
; angle: undefined for 0 [,bt for context]
> (angle 0.0)
0
> (angle 0+0.0i)
0.0
floating point & complex numbers make my head hurt sometimes. (I think the most suprizing thing is that (angle 0.0) gives exact zero)

oh hey TR gets (angle 0)
wrong

@jacobm has joined the channel

@florence The racket docs are too precise with regards to angle
. (I am comparing with http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_idx_576 )

And I don’t understand why (angle 0.0) is excact 0.

Probably because it is a polar coordinate with a very very small radial value on the positive x axis

meaning it has a defined rotation of 0

(I would have expected it to be 0.0 as well though)

since you cant have mixed exact/inexact complexes

could be a bug, but iirc exact zero shows up in a few surprising places

I suppose 0.0 is interpreted to mean that the complex part is exact 0.

But do complex numbers have separate exactnesses for the real and complex part?

it looks like they do iff the exact part is zero?
> 0+0.0i
0+0.0i
> 1+0.0i
1.0+0.0i

I see that a in R6RS they list as a change: “Scheme’s real number objects now have an exact zero as their imaginary part.”

In R5RS I believe the (in)exactness described both parts.

@jacobm welcome!

Curious why Racket provides a mechanism to provide
for-meta
/for-syntax
/for-template
. Isn’t provide
ing at phase 0 relative to the enclosing submodule, and require
ing for-meta
/for-syntax
/for-template
at the use-site does the same thing?

for-meta
/for-syntax
/for-template
don’t actually do any phase shifting of bindings when used with provide
, they just select which phase the binding to be provided is at.

To make that more concrete, a module can define two different bindings that are both named x
at phase 0 and phase 1. (provide x)
will provide the phase 0 binding, while (provide (for-syntax x))
will provide the phase 1 binding.

Neither will provide the phase 0 binding at phase 1 or the phase 1 binding at phase 0. Phase shifting at the require site is necessary to do that.