A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
24
Task/Generic-swap/Racket/generic-swap.rkt
Normal file
24
Task/Generic-swap/Racket/generic-swap.rkt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#lang racket/load
|
||||
|
||||
(module swap racket
|
||||
(provide swap)
|
||||
|
||||
;; a simple macro to swap two variables
|
||||
(define-syntax-rule (swap a b)
|
||||
(let ([tmp a])
|
||||
(set! a b)
|
||||
(set! b tmp))))
|
||||
|
||||
;; works fine in a statically typed setting
|
||||
(module typed typed/racket
|
||||
(require 'swap)
|
||||
|
||||
(: x Integer)
|
||||
(define x 3)
|
||||
|
||||
(: y Integer)
|
||||
(define y 4)
|
||||
|
||||
(swap x y)
|
||||
(printf "x is ~a~n" x)
|
||||
(printf "y is ~a~n" y))
|
||||
Loading…
Add table
Add a link
Reference in a new issue