Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 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