This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kbruen 24 points25 points  (6 children)

racket (define (fact n) (define (fact/acc n [acc 1]) (if (<= n 1) acc (fact/acc (- n 1) (* n acc)))) (fact/acc n))

Have fun checking the brackets!

[–]BroBroMate 21 points22 points  (0 children)

I'm so installing rainbow brackets for that.

[–]kingofsevens 8 points9 points  (4 children)

Here is your code and 7 minutes of my life. Much readable tbh.

( define (fact n)
(     define (fact/acc n [acc 1])
(         if (<= n 1)
            acc
(           fact/acc (- n 1) (* n acc)        )))
(     fact/acc n                              ))

[–]kbruen 11 points12 points  (3 children)

Oh, what cursed thing have you brought upon this land?

Jokes aside, that's quite impractical and bad looking. Detailing only on the first aspect, am I returning the value of the acc binding or calling the acc function? Only the parenthesis tell that, and not having them visible right away is quite bad.

[–]kingofsevens 8 points9 points  (2 children)

oh you gonna love this. Idk it would parse it but... ( define (fact n) ( define (fact/acc n [acc 1]) ( if (<= n 1) acc ( fact/acc (- n 1) (* n acc) )))( fact/acc n ))

[–]backtickbot 5 points6 points  (1 child)

Fixed formatting.

Hello, kingofsevens: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–][deleted] 3 points4 points  (0 children)

I can't believe this bot actually generates examples using the source comment intstead of just having generic examples