laurent.orseau
2020-7-25 07:24:07

Do you just need to get the next ref, or do you need to go through all refs anyway?


rp
2020-7-25 07:24:57

At the moment I just need to get the next reference. Maybe one day in the future I’ll need to go through them all.


rp
2020-7-25 07:25:15

But there’s no need to make any great effort to solve this problem for me - the major need is accomplished.


laurent.orseau
2020-7-25 07:26:05

I think we all took this as a puzzle ;)


sorawee
2020-7-25 07:27:17

Is it possible to create a macro that produces a list of all bound identifiers at that position?


sorawee
2020-7-25 07:27:56

So, not only top level identifiers, but also local variables introduced from let, etc.


rp
2020-7-25 07:30:06

I mean it can’t be /that/ fast I guess anyway - there are 17 million of them to go through after all!


laurent.orseau
2020-7-25 08:28:52

Well, I believe you may be underestimating Racket :wink: here’s an example that it can be blazingly fast (of course it does almost nothing per iteration): #lang racket (define ups (build-list 26 (λ (i) (integer->char (+ i (char->integer #\A)))))) (define nums (build-list 10 (λ (i) (integer->char (+ i (char->integer #\0)))))) (define last #f) (define n 0) (time (for* ([x1 (in-list ups)] [x2 (in-list ups)] [x3 (in-list ups)] [x4 (in-list nums)] [x5 (in-list nums)] [x6 (in-list nums)]) (set! n (+ n 1)) (set! last (string x1 x2 x3 x4 x5 x6)))) n last Result when run from the terminal: $ racket richard_parsons_matter.rkt cpu time: 292 real time: 292 gc time: 21 17576000 "ZZZ999"


laurent.orseau
2020-7-25 08:30:41

(of course if you need to do something that takes 1ms per iteration of the loop, that will take 17 576 seconds)


laurent.orseau
2020-7-25 08:34:33

One horrible solution is to use check-syntax on the module, and check for all available identifiers at the syntax source location. Complicated and overkill I guess.


laurent.orseau
2020-7-25 08:34:59

Though there’s an intriguing ‘meta’ feel to it :wink:


laurent.orseau
2020-7-25 08:36:03

I had to do something close (though probably not ideal) for the extract-function script: https://github.com/Metaxal/quickscript-extra/blob/master/scripts/extract-function.rkt


laurent.orseau
2020-7-25 09:07:46

Has anyone written a list-box+search-box standalone widget by any chance? (@alexharsanyi?) The contents of the list-box are filtered by whatever is written in the text-field


rokitna
2020-7-25 09:08:50

I’d love to know if there’s a nice way to do this (edit to clarify: a nice way for a macro to get a listing of the variables in scope). I’ve been casually looking for some way to get a list of currently-known-to-be-bound variables for a while.

(I assume it’s more challenging when a macro call is being partially expanded in a definition context, since later definitions haven’t been processed yet to find out all the variables they bind. But I think even a solution that excluded those variables would be good enough for me.)


alexharsanyi
2020-7-25 09:21:47

laurent.orseau
2020-7-25 09:53:53

Thanks. I’m already past that point anyway :slightly_smiling_face:


laurent.orseau
2020-7-25 09:57:31

Btw, I really like that you always include a demo, it’s very helpful


laurent.orseau
2020-7-25 12:46:58

Have you found a way to make the list-box react on #\return? only #\space works for me


samth
2020-7-25 14:44:47

In general, no, there’s not a way to get this information. I could give some reasons why it’s tricky to figure out what the right answer is but the basic answer is that the API doesn’t exist


greg
2020-7-25 14:55:00

@sorawee Is there an evil-forward-sexp-begin? That sounds like the command you would want. (idk evil mode).


greg
2020-7-25 14:55:34

Doing two forward-sexp commands followed by a backward-sexp command will put point before the # as you want.


greg
2020-7-25 14:57:10

racket-mode does give the # and ' characters Emacs’ “Prefix Character” char-syntax classification in the buffer. So programming mode commands like forward-sexp, modes like paredit, and so on, should all work correctly.


greg
2020-7-25 14:58:16

So “word” is a natural language editing concept, and “sexp” is a program code editing concept, in Emacs world.


sorawee
2020-7-25 14:58:29

Thanks!


greg
2020-7-25 14:58:35

“sexp” can mean “expression” or “block” in a non-s-expression lang, in Emacs, too.


greg
2020-7-25 15:01:32

All the Emacs “forward-” commands mean “forward to the end of the thing”. Often you want “forward to the end of the current thing, or if already at the end, then beginning of the next thing”. So you have to do the 2X forward, 1X backward dance. Which is annoying. So I totally get why there is an evil-mode “forward-word-begin” command; nice! But there probably needs to be a forward-sexp-begin flavor, too.


laurent.orseau
2020-7-25 15:16:55

laurent.orseau
2020-7-25 15:17:34

(package created)


cancandan
2020-7-25 19:37:25

Are there libs like numpy for racket?


cancandan
2020-7-25 19:46:06

Yes there seems to be a dataframe lib.


cancandan
2020-7-25 19:46:36

Another q: is it possible to make android ios apps or web frontend like clojurescript?


soegaard2
2020-7-25 19:53:28

@cancandan What kind of math are you interested in? Floating matrices are here: https://docs.racket-lang.org/manual-flomat/index.html?q=sci


cancandan
2020-7-25 19:54:48

Smthg like numpy, pandas


soegaard2
2020-7-25 19:55:21

I don’t know pandas.



cancandan
2020-7-25 19:56:10

Its on top of numpy, lots of useful stuff


soegaard2
2020-7-25 19:57:15

cancandan
2020-7-25 19:57:39

Right have to check that



soegaard2
2020-7-25 19:59:38

It seems data-table does have documentation, but it doesn’t appear on http://docs.racket-lang.org\|docs.racket-lang.org . I don’t know why.


pknb.dev
2020-7-25 20:15:16

@pknb.dev has joined the channel


alexharsanyi
2020-7-25 22:25:02

I have not tried it, but the toplevel frame or dialog capture the return key, so the widgets might never see it…


rokitna
2020-7-25 23:20:03

The reasons sound like they’d be fascinating. Anyway, thanks for confirming that I’m not overlooking some way to do this. :) It’s not something urgent to me, just something I probably would have explored building things on if it existed.