leafac
2016-11-14 12:16:06

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


lexi.lambda
2016-11-14 18:18:19

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


leandro
2016-11-14 18:18:55

wrong leandro :stuck_out_tongue:


lexi.lambda
2016-11-14 18:19:20

haha, oops


lexi.lambda
2016-11-14 18:19:27

sorry about that :p


jab
2016-11-14 18:37:15

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?


jab
2016-11-14 18:38:29

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


jab
2016-11-14 18:38:40

and then resume alternating


leandro
2016-11-14 18:39:20

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


leafac
2016-11-14 18:39:31

I was about to say that :slightly_smiling_face:


leandro
2016-11-14 18:39:42

well after all we have the same name


leafac
2016-11-14 18:39:57

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


jab
2016-11-14 18:40:43

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


jab
2016-11-14 18:40:56

though maybe it’s too clever?


leafac
2016-11-14 18:41:03

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


leandro
2016-11-14 18:41:03

nah, it’s just a bit of math


leandro
2016-11-14 18:41:23

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


leandro
2016-11-14 18:41:32

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


jab
2016-11-14 18:44:49

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.


leafac
2016-11-14 18:45:59

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


leafac
2016-11-14 18:46:50

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


jab
2016-11-14 18:48:14

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


leafac
2016-11-14 18:49:02

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


jab
2016-11-14 18:52:17

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?


lexi.lambda
2016-11-14 18:53:18

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


lexi.lambda
2016-11-14 18:54:01

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


jab
2016-11-14 18:55:54

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?


lexi.lambda
2016-11-14 18:56:40

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


lexi.lambda
2016-11-14 18:56:46

I just use DrRacket, though, honestly


jab
2016-11-14 18:59:29

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.


lexi.lambda
2016-11-14 19:02:42

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


lexi.lambda
2016-11-14 19:03:35

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


jab
2016-11-14 19:04:26

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…


lexi.lambda
2016-11-14 19:04:56

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


jab
2016-11-14 19:04:57

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


jab
2016-11-14 19:05:06

cool, thanks again!


leafac
2016-11-14 19:24:45

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


lexi.lambda
2016-11-14 19:30:57

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


leandro
2016-11-14 19:41:59

@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


leandro
2016-11-14 19:43:35

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


jbelmont
2016-11-14 20:23:44

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


lexi.lambda
2016-11-14 21:02:19

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


jbelmont
2016-11-14 21:06:02

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


lexi.lambda
2016-11-14 21:06:46

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.


jbelmont
2016-11-14 21:10:17

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


jbelmont
2016-11-14 21:12:14

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


lexi.lambda
2016-11-14 21:14:24

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.


jab
2016-11-14 21:25:47

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.


jab
2016-11-14 21:26:17

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


jab
2016-11-14 21:28:06

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)


jab
2016-11-14 21:29:29

(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?)


lexi.lambda
2016-11-14 21:31:10

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. ;)


lexi.lambda
2016-11-14 21:32:04

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


lexi.lambda
2016-11-14 21:32:40

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


jab
2016-11-14 21:38:45

oh, nice trick! thanks lexi.lambda!


jbelmont
2016-11-14 21:57:35

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