Ask HN: What piece of code/codebase blew your mind when you saw it?

Hacker News

Realest
Joined
Sep 15, 2022
Messages
72,648
Reaction score
15
BC
฿0
Dividends
0
Mine was when I learned a subset of recursion called mutual recursion. It was for a pair of function to determine if a number was odd or even.
(define (odd? x)

Code:
  (cond


    [(zero? x) #f]


    [else (even? (sub1 x))]))
(define (even? x)

Code:
  (cond


    [(zero? x) #t]


    [else (odd? (sub1 x))]))



Comments URL: https://news.ycombinator.com/item?id=33413124

Points: 10

# Comments: 0

Continue reading...
 

Users who are viewing this thread

Cookies are required to use this site. You must accept them to continue using the site. Learn more…