
thx

with regard to the macro, what I actually want right now is something like (function arg1) to expand to something like (function (arg 1))

I was thinking maybe it would be possible if there was a list of understood "arg"s and the inputs to the function are converted to strings, check if the first part of the string matches an understood arg, then send the value of the rest of the string to the function?

does that sound like a workable path?

@me1 I think it could be a potentially workable idea if you restrict the set of possible functions you might be interested in. Otherwise I think it’d be likely you’d have too many valid matches if the namespace of possible functions is unlimited.

@wcrichto has joined the channel

Quick question for the channel. If I want to find something like the source for the “for” construct (I assume it’s a macro somewhere?), where should I look?

@wcrichto I’ll give you two answers. The first is the direct answer to your question: for
’s source code comes from the module racket/private/for
, which is in the racket/racket GitHub repo in racket/collects/racket/private/for.rkt
. The second is perhaps a slightly more useful answer: if you want to find the source code for various forms and functions, you can use DrRacket to right-click on an identifier and click “Open Defining File”, or you can use racket-mode in emacs and use racket-visit-definition
.

Got it. Thanks @lexi.lambda.

How does one convert #\5 to 5?

I know of display
, but doesn’t that have side effects?

display
doesn’t convert; it just displays. There isn’t a built-in char->number
(as far as I know), but you could either create a string containing only that one character and use string->number
, or you could write your own char->number
.

(- (char->integer #\5) 48)
?

ah is that the unicode conversion

I didn’t know that

My motivation for all this was to try and figure out how to do a number in some base into a sequence hehe

I know there’s an algorithm for doing floor division and modulo, but I want something that works for negative numbers too

simplest thing would be to re-use string->number
, e.g., (string->number (string #\5))

Ohh I see

(string->number (string #\- #\5))

Earlier I thought you meant something else

Now I see both approaches work

ahh I see thanks