PasteRack.org
Paste # 72418
2017-06-28 18:40:07

Fork as a new paste.

Paste viewed 514 times.


Embed:

Example of 2D syntax

  1. ; For more info, see: https://docs.racket-lang.org/2d/index.html
  2.  
  3. #lang 2d racket
  4. (require 2d/cond)
  5.  
  6. (define (same? a b)
  7.   #2dcond
  8.   ╔═════════════╦═══════════════════════╦═════════════╗
  9.                       (pair? a)        (number? a) 
  10.   ╠═════════════╬═══════════════════════╬═════════════╣
  11.    (pair? b)    (and (same? (car a)        #f      
  12.                             (car b))               
  13.                      (same? (cdr a)                
  14.                             (cdr b)))              
  15.   ╠═════════════╬═══════════════════════╬═════════════╣
  16.    (number? b)           #f              (= a b)   
  17.   ╚═════════════╩═══════════════════════╩═════════════╝)
  18.  
  19. (same? 1 2)
  20. (same? (list* 1 2 3) (list* 1 2 (+ 1 2)))
  21. (same? 1 (list* 1 2))
  22. ; use `list*` instead of `list` because the example doesn't
  23. ; understand the implicit null at the end of a list.

=>

#f

#t

#f