You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
659 B
Racket
23 lines
659 B
Racket
8 years ago
|
#lang br/quicklang
|
||
8 years ago
|
|
||
|
(define (read-syntax path port)
|
||
|
(strip-bindings
|
||
8 years ago
|
#`(module mod "lang.rkt"
|
||
8 years ago
|
#,@(for*/list ([triangle-str (in-list (string-split (port->string port) "\n"))])
|
||
|
`(triangle ,@(string-split triangle-str))))))
|
||
8 years ago
|
(provide read-syntax)
|
||
8 years ago
|
|
||
|
(define-macro (mb . TRIANGLES)
|
||
|
#'(#%module-begin
|
||
|
(length (filter valid-triangle? (list . TRIANGLES)))))
|
||
|
(provide (rename-out [mb #%module-begin]))
|
||
|
|
||
|
(define-macro (triangle A B C)
|
||
8 years ago
|
#'(map string->number (list A B C)))
|
||
8 years ago
|
(provide triangle)
|
||
|
|
||
|
(define (valid-triangle? triangle)
|
||
|
(match-define (list a b c) triangle)
|
||
|
(and (> (+ a b) c)
|
||
|
(> (+ b c) a)
|
||
|
(> (+ a c) b)))
|