Skip to content
Snippets Groups Projects
Commit a3075b0e authored by Denis Shirshov's avatar Denis Shirshov
Browse files

60

parent 67f8275f
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@
(define *f (make-rounded-op * exact-floor))
(define *c (make-rounded-op * exact-ceiling))
(define (true? x) (if (equal? #f x) #f #t))
(define (true? x) (and x #t))
(define (!= a b)
(not (= a b)))
......@@ -263,6 +263,8 @@
(check-equal? (*c (tan 1) (tan -2)) 4)
(check-pred true? #t)
(check-pred true? (+ 2 2))
(check-pred true? (hash 'a 10))
(check-pred true? 0)
(check-pred true? null)
(check-equal? (true? #f) #f)
......
......@@ -36,22 +36,3 @@
(define-macro (__t text)
`(show-status-in-let debug-output ,text))
(define-syntax (--- stx)
(syntax-case stx ()
((_ parameters ...)
(with-syntax ((frmt #'(for/fold
((s "~n"))
((i (reverse (list parameters ...))))
(string-append "~a " s))))
#'(printf frmt parameters ...)))))
(define (print-list lst)
(for ((i lst))
(println i)))
(define (---- obj)
(cond
((list? obj) (print-list obj))
((hash? obj) (print-list (for/list (((k v) obj)) (cons k v))))
(else obj)))
......@@ -28,6 +28,9 @@
(define (write-file filename v)
(display-to-file v filename #:exists 'replace))
(define (append-file filename v)
(display-lines-to-file v filename #:exists 'append))
(define (read-file filename)
(file->string filename #:mode 'text))
......@@ -76,3 +79,28 @@
; read serialized data and converts it to a normal value
(define (read-serialized-data-from-file filepath)
(deserialize (file->value filepath)))
;;; shorthands
(define-syntax (--- stx)
(syntax-case stx ()
((_ parameters ...)
(with-syntax ((frmt #'(for/fold
((s "~n"))
((i (reverse (list parameters ...))))
(string-append "~a " s))))
#'(if (debug-output)
(append-file (debug-output) (format frmt parameters ...))
(printf frmt parameters ...)
)))))
(define (print-list lst)
(for ((i lst))
(if (debug-output)
(append-file (debug-output) i)
(println i))))
(define (---- obj)
(cond
((list? obj) (print-list obj))
((hash? obj) (print-list (for/list (((k v) obj)) (cons k v))))
(else obj)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment