me1
2017-11-26 14:30:45

thx


me1
2017-11-26 14:32:16

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


me1
2017-11-26 14:35:31

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?


me1
2017-11-26 14:35:49

does that sound like a workable path?


abmclin
2017-11-26 17:05:38

@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
2017-11-26 21:54:19

@wcrichto has joined the channel


wcrichto
2017-11-26 21:55:21

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?


lexi.lambda
2017-11-26 22:08:10

@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.


wcrichto
2017-11-26 23:20:39

Got it. Thanks @lexi.lambda.


slack1
2017-11-27 00:02:08

How does one convert #\5 to 5?


slack1
2017-11-27 00:02:14

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


jaz
2017-11-27 00:07:17

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.


greg
2017-11-27 00:13:52

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


slack1
2017-11-27 00:14:07

ah is that the unicode conversion


slack1
2017-11-27 00:14:09

I didn’t know that


slack1
2017-11-27 00:14:41

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


slack1
2017-11-27 00:15:04

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


jaz
2017-11-27 00:15:51

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


slack1
2017-11-27 00:16:18

Ohh I see


jaz
2017-11-27 00:16:20

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


slack1
2017-11-27 00:16:34

Earlier I thought you meant something else


slack1
2017-11-27 00:16:44

Now I see both approaches work


slack1
2017-11-27 00:17:29

ahh I see thanks