PasteRack.org
Paste # 58952
2016-07-26 12:20:26

Forked from paste # 60064.

Fork as a new paste.

Paste viewed 6178 times.


Embed:

2d

  1. #lang 2d racket
  2. (require 2d/cond)
  3.  
  4. (define (same? a b)
  5.   #2dcond
  6.   ╔═════════════╦═══════════════════════╦═════════════╗
  7.                       (pair? a)        (number? a) 
  8.   ╠═════════════╬═══════════════════════╬═════════════╣
  9.    (pair? b)    (and (same? (car a)        #f      
  10.                             (car b))               
  11.                      (same? (cdr a)                
  12.                             (cdr b)))              
  13.   ╠═════════════╬═══════════════════════╬═════════════╣
  14.    (number? b)           #f              (= a b)   
  15.   ╚═════════════╩═══════════════════════╩═════════════╝)
  16.  
  17. (same? 1 2)
  18. (same? 1 1)
  19. (same? 1.0 1)
  20. (same? 1 "1")
  21. (same? '(1) 1)
  22. (same? '(1 . (2 . 3)) '(1 . (2 . 3)))

=>

#f

#t

#t

2dcond: all of the y-direction questions were false (x

coordinate 2 was true)

#f

#t