michael.hamel80
2020-7-24 08:26:23

@michael.hamel80 has joined the channel


ego
2020-7-24 09:32:12

can anyone recommend a Racket repl with syntax highlighting?


laurent.orseau
2020-7-24 09:39:54

DrRacket? Or do you mean for use in a terminal?


ego
2020-7-24 09:40:52

yes, in a terminal


laurent.orseau
2020-7-24 09:42:13

I don’t know of one, sorry


laurent.orseau
2020-7-24 09:58:30

Maybe Rash does something similar, but I haven’t checked: https://docs.racket-lang.org/rash/index.html


laurent.orseau
2020-7-24 09:59:13

(it’s not a racket repl, but my thinking was that maybe it does syntax color, which could then be extracted to make a repl)


ury.marshak
2020-7-24 14:24:12

@ury.marshak has joined the channel


maueroats
2020-7-24 18:23:22

re: Repl with syntax highlighting. Have you considered doing your repl in an emacs window? I use racket-mode and get syntax highlighting in the Racket repl as well as in racket files. @ego


rp
2020-7-24 20:49:31

How can I get all combinations of two lists?


spdegabrielle
2020-7-24 20:51:42

Like a ‘power set’ in mathematics?


rp
2020-7-24 20:52:13

I’m not sure, I don’t know what a power set is. I thought it was called permutations in maths?


rp
2020-7-24 20:52:53

If I use for/list I think that it takes one member of each list in turn. I want each member of the first list to take each member of the second list in turn, if that makes sense.


rp
2020-7-24 20:53:25

I last studied maths 22 years ago though, so I could very easily be wrong!


sorawee
2020-7-24 20:54:21

Use for*/list.


rp
2020-7-24 20:54:43

@sorawee Great, I’ll try that. Thanks.


sorawee
2020-7-24 20:56:49

@greg: this is not directly related to Racket Mode, but seems to be a problem from interaction between Evil and Racket Mode. Suppose I have:

[a]bc #'def where [...] indicates the current point. If I run evil-forward-word-begin, it moves the point to:

abc #[']def which is incorrect. Note that this problem only occurs in Racket Mode. If I switch to text-mode, it would move the point to:

abc [#]'def correctly.

This is especially annoying when I “delete a word forward” using Evil, because it would result in 'def rather than #'def.

Do you have an idea what could cause this behavior?


laurent.orseau
2020-7-24 21:12:22

Just for the sake of knowledge, this is called a Cartesian product and there’s even a racket function for it: https://docs.racket-lang.org/reference/pairs.html?q=Cartesian#%28def._%28%28lib._racket%2Flist..rkt%29._cartesian-product%29%29\|https://docs.racket-lang.org/reference/pairs.html?q=Cartesian#%28def._%28%28lib._racket%2Flist..rkt%29._cartesian-product%29%29 However, if you have just two lists, don’t even bother with it and just use for*/list.


rp
2020-7-24 21:16:18

Thanks, I actually have six lists. It’s all my possible project references of the form “AAA001” up to “ZZZ999”. Turns out there are quite a lot of them and this is a slow way of dealing with them :(


maueroats
2020-7-24 21:29:22

Try an experiment to see if it’s because the # is not a legal character in a “word”. Is there anything else like that? \ maybe? _ ? There’s some modify-syntax-entry stuff in racket-common.el so I would guess this isn’t an accident just not what you want. Googling the function that you mention shows a lot of people suffer. :slightly_smiling_face:


ego
2020-7-24 21:35:28

I’m sure emacs is probably the best option… but I’ve never touched emacs before and I’m new to Racket, so I didn’t really feel like tackling two new things at the same time


ego
2020-7-24 21:37:02

I wonder if it’s possible to get “just the repl” part of emacs+racket-mode working inside of VS Code or Sublime Text


laurent.orseau
2020-7-24 21:43:53

Indeed that’s 17 million possibilities. Depending on what you do for each possibility, it can take a while to go through. (cartesian-product is a rather slow function, i still recommend for*/list). Is there any way you can avoid going through it all?


rp
2020-7-24 22:03:55

I think I’ve solved it. The function I need is simply to find the next consecutive reference, given an existing one. I tried for*/list but it wouldn’t finish. I switched it to for*/stream, and that still took about 10 seconds. I’ve now written a cond statement which destructures the reference into a list of chars and then manually increases it by checking each of the fields in turn from the last to the first to work out which characters to change. It’s quick now, but not as cool as using a stream!


notjack
2020-7-24 22:23:14

would you be willing to share the code? this sounds like an interesting problem domain and I’d like to see if the for forms could be improved to handle your use case.


rp
2020-7-24 22:27:13

Sure, though I’m surprised it is interesting. I’ll post it on a pastebin and send the link, if that works?


rp
2020-7-24 22:30:26

@notjack I’ve deleted the for*/list code though that didn’t work. Do you want me to dig it up for you? I’m happy to, if that is what you’re interested in.


notjack
2020-7-24 22:40:10

I’m mostly interested in the working code that you ended up with. Pastebin would be great.


notjack
2020-7-24 22:40:45

(I work on stream processing libraries for fun so I sometimes have an odd definition of “interesting”)


rp
2020-7-24 22:42:31

Ha, fair enough. Here’s the current code: https://pastebin.com/3mPaAtEu


rp
2020-7-24 22:43:43

What I was doing before was creating a stream of matter references in order and then finding the reference after the current one. With 17 million references in total, it seemed to take quite awhile.


alexharsanyi
2020-7-25 00:03:34

As a follow-up from my previous pull request, I converted most of the plot tests to use draw steps, rather than relying on manual testing. The new pull request is a bit large, but most of the files are data files in suport of the tests (some tests generated more than 200 test plots and there are about test 600 plots in total). I will leave this pull request open for about a week before merging it, to allow interested people to look at it and provide feedback.

https://github.com/racket/plot/pull/63


samth
2020-7-25 01:17:23

Impressive


sorawee
2020-7-25 04:41:44

Here’s my take at this problem:

(define (next-reference r) (define supported-chars `((,char-upper-case? . #\A) (,char-numeric? . #\0))) (define (on-done done? acc) (cond [done? (list->string acc)] [else (error "Maximum matter reference reached")])) (unless (= 6 (string-length r)) (error "Ill-formed reference")) (for/fold ([done? #f] [acc '()] #:result (on-done done? acc)) ([char (reverse (string->list r))]) (cond [done? (values #t (cons char acc))] [else (define next-char (integer->char (add1 (char->integer char)))) (apply values (or (for/or ([mode (in-list supported-chars)]) (and ((car mode) char) (if ((car mode) next-char) (list #t (cons next-char acc)) (list #f (cons (cdr mode) acc))))) (error "Ill-formed reference")))]))) (next-reference "ABC999")


cancandan
2020-7-25 05:17:11

@cancandan has joined the channel


rp
2020-7-25 05:48:22

That’s very kind of you to code that. I have to admit, I don’t quite understand it, but it is definitely better than mine - shorter, less repetition of functions, and all contained in one function. Mine has its own module, the code is so long. I’ll scratch my head over the for/fold stuff and see if I can work it out.