
@jab: Seems like you’d be interested in “in-cycle”. Here’s what I mean:
> (for ([i (in-range 0 10)]
[color (in-cycle '("black" "red"))])
(displayln color))
black
red
black
red
black
red
black
red
black
red
It seems like “in-cycle” is the intent you encoded with the “((row + col) % 2)” index.

@jab: I agree with @leafac that in-cycle
is clearer, but aside from that I think your code is fine

wrong leandro :stuck_out_tongue:

haha, oops

sorry about that :p

lexi.lambda, leafac: but notice that with a checkerboard, not only does every cell in a row alternate colors, but each row’s starting cell alternates colors. so if you just linearize the 8x8 matrix and apply a (red, black) cycle to cells 0–63, you end up with columns of red and black stripes, not a checkerboard. how would you use in-cycle with an 8x8 matrix to still end up with a checkerboard?

in other words, the code snippet leafac posted above is wrong: every 8 iterations you need to repeat the previous color

and then resume alternating

I guess you could in-cycle
a row that in-cycle
s the columns?

I was about to say that :slightly_smiling_face:

well after all we have the same name

(in-cycle ’((”red” “black”) (”black” “red”)))

leafac, leandro: i originally had something like that, but when i realized i could do it the way i did, i changed it as it seemed more elegant

though maybe it’s too clever?

@jab: More power to you, then :slightly_smiling_face:

nah, it’s just a bit of math

but i’d try to make it more polite by naming it something nice and self-explanatory

and if you’re gonna do that, you might as well use in-cycle
:stuck_out_tongue:

leafac, leandro: but (in-cycle '((”red” “black”) (”black” “red”)))
isn’t right either. curious if you’d still prefer an in-cycle approach after you work up a correct solution using it.

What is wrong with (in-cycle '(("red" "black") ("black" “red”)))
? (Please note that you’d still have to in-cycle
on the resulting list.)

I.e., (for ([colors (in-cycle '(("red" "black") ("black" “red”)))]) (for ([color (in-cycle colors]) …

ah right, i see what you mean. comparing those two now, i think i do prefer the in-cycle approach. thanks :slightly_smiling_face:

:+1: I’m glad you like it.

I like to use the Mac keyboard shortcut alt+shift+arrow key to grow selection by word, but this isn’t enabled by default in racket. anyone know if this is on purpose, open to change if so, and overridable in any case?

I used to find that weird, too, but DrRacket overrides the keybindings to make them more useful for editing s-expressions, and I’ve grown to appreciate them a lot

the keybindings are basically simple structural editing, but they’re much more intuitive than paredit keybindings

lexi.lambda Thanks! As someone who’s new to all of these, I’m wondering if I should just skip right to learning parinfer (from the Clojure world). Is that available for Racket?

unfortunately, I don’t think there’s a DrRacket plugin for it, but you can use emacs + racket-mode if you want to really take the lisp tooling plunge

I just use DrRacket, though, honestly

lexi.lambda If it’s good enough for you, I’ll stick with it too. I’m an old Vim user and never made the emacs plunge beyond a basic emacs config. Is there a good tutorial anyone could refer me to? I just googled “drracket structural editing” and didn’t immediately turn up relevant results.

Not that I know of, though I kind of just stumbled into them by using DrRacket for a while. Basically, ⌥← jumps backwards an s-expression, and ⌥→ jumps forward. Similarly, ⌥⇧← selects the previous s-expression, and ⌥⇧→ selects the next one. Additionally, ⌥↓ jumps “into” an s-expression, and ⌥↑ jumps “out”.

I think that’s really it, honestly, since you can do the rest with the usual select/copy/cut/paste keybindings.

lexi.lambda Thanks for typing all that out! but hm, "⌥⇧← selects the previous s-expression" isn’t working for me, I wonder what’s going on…

(gotta go for a bit, but I’ll answer any questions if I can later)

(behaves the same as if shift isn’t pressed, i.e. just makes cursor jump without a selection

cool, thanks again!

@jab: I just tested ⌥⇧←
and it’s working for me. Could it be that you have “Treat alt key as meta” enabled on Preferences > Editing > General Editing? This changes the meaning of ⌥, which broke some shortcuts for me when I had it enabled.

@jab: Yeah, I’m not sure what could be the issue there.

@jab, I’m a vim user too, but since I use and abuse tmux, using vimux
was a nice way of getting a REPL and a flow where I can just edit with my vim powers, and execute at a keystroke on the REPL, side by side

(in case you were trying dr racket for the execution environment)

hello everybody I have a quick question. Is anyone here using typed racket and if so where are good starting projects that are using typed racket

@jbelmont: I agree with Geoff’s answer on Twitter that asking the mailing list is probably your best bet, but I can try and answer questions about TR if you have them. I’m not sure if I’m familiar with any good codebases to look at that are using TR right now, though.

Hello @lexi.lambda yeah I was planning on asking the mailing list but wanted to ask the same question here. I guess what I am most curious about is if people here use Dr. Racket IDE for Typed Racket or what editors/tools people are using to develop in Typed Racket

I think the most common editors by a fair margin are DrRacket or emacs + racket-mode. After that there’s probably a pretty significant dropoff.

I see yeah I was planning on using Dr. Racket for some scratch projects with Typed Racket. Seems like I just need to get my hands dirty and pick what works best for me

I used to believe in using vim for everything but now I just like the comforts of a stripped down editor like atom or vs code and using the command line

I would definitely give DrRacket a try if you are open to it. It doesn’t look super pretty, but it’s a much more capable editor than it might seem, and it works very well with Racket languages of all kinds. In TR, it supports type tooltips, for example.

leafac: I tried disabling “treat alt as meta” and alt+shift+arrow still doesn’t work (i.e. still behaves as if shift isn’t pressed). (Going to re-enable it if that’s not the issue since I use alt+f and alt+b all the time.) Anything else you can think of? Thanks so much for the help.

oh wow, just randomly thought to try alt+shift+f and alt+shift+b and that works!

btw, is anyone working on parinfer for drracket? or is there another code auto-formatter it’s possible to use? in principle i think i’m a big fan of having tooling save users such trouble (once less superficial decision to make)

(i know parinfer is more than a code formatter. i meant, if there is no parinfer for drracket coming soon, is there any integrated auto-formatting tool?)

I don’t know if anyone is working on a parinfer plugin, but I’m sure it would be welcome if you wanted to write one. ;)

There is an integrated indent tool, though. ⌘I reindents everything, but usually I just press Tab to reindent lines within the current selection.

Combined with the s-expression selection shortcuts, it’s really easy to reindent a whole form by selecting it and pressing Tab.

oh, nice trick! thanks lexi.lambda!

Thanks @lexi.lambda for the tips, I am definitely going to use Dr. Racket