(def (u8vector->uint bv (guard #t))
(def (compute bv)
(let ((l (fx- (u8vector-length bv) 1)))
(let loop ((s 0) (i 0))
(if (< i l)
(loop (+ s (* (u8vector-ref bv i) (expt 256 (- l i)))) (+ i 1))
(+ s (* (u8vector-ref bv i) (expt 256 (- l i))))))))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
gcc -c sum_to_n.c | |
gfortran sum_to_n.f90 sum_to_n.o -o sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gambit: | |
gfortran -c sum_to_n.f90 -o sum_to_n.o | |
gsc -ld-options sum_to_n.o sum_to_n.scm | |
clean: | |
rm sum_to_n.o* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-syntax de | |
(syntax-rules (à) | |
((de x à y) (cond ((> x y) (let loop ((z y) (l '())) | |
(cond ((< z x) (loop (+ z 1) (cons z l))) | |
((= z x) (cons z l))))) | |
((= x y) x) | |
((< x y) (let loop ((z y) (l '())) | |
(cond ((> z x) (loop (- z 1) (cons z l))) | |
((= z x) (cons z l))))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gxi -:d2- -e '(define x (make-u8vector 10000000))(let loop () (loop))' | |
*** GC: 967us, 2.1M alloc, 5.0M heap, 858K live (17% 874512+4512) | |
*** GC: 753us, 3.3M alloc, 7.0M heap, 1.8M live (25% 1785408+49800) | |
*** GC: 864us, 5.5M alloc, 8.1M heap, 2.4M live (29% 2411696+70120) | |
*** GC: 849us, 7.2M alloc, 30M heap, 12M live (42% 2807472+10147656) | |
*** GC: 839us, 20M alloc, 30M heap, 12M live (42% 2807584+10147656) | |
*** GC: 970us, 33M alloc, 30M heap, 12M live (42% 2807584+10147656) | |
*** GC: 813us, 45M alloc, 30M heap, 12M live (42% 2807584+10147656) | |
*** GC: 913us, 58M alloc, 30M heap, 12M live (42% 2807584+10147656) | |
*** GC: 846us, 71M alloc, 30M heap, 12M live (42% 2807584+10147656) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(time (u8vector->uint16-0 u16)) | |
0.000004 secs real time | |
0.000005 secs cpu time (0.000004 user, 0.000001 system) | |
no collections | |
64 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u16)) | |
0.000004 secs real time | |
0.000005 secs cpu time (0.000005 user, 0.000000 system) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defsyntax (reverse-me stx) | |
(syntax-case stx () | |
((macro . args) | |
(with-syntax () | |
(datum->syntax #'macro (reverse (syntax->datum #'args))))))) | |
;; > (reverse-me "backwards" "am" "I" values) | |
;; "I" | |
;; "am" | |
;; "backwards" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(begin-syntax | |
(def (split-parg stx) | |
(datum->syntax stx | |
(stx-map string->symbol | |
(string-split (symbol->string (stx-e stx)) #\:)))) | |
(def (stx-cadr stx) | |
(stx-car (stx-cdr stx)))) | |
(defsyntax (predlambda stx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import :std/misc/text | |
:std/misc/list | |
:std/pregexp | |
:std/iter | |
:std/srfi/13 | |
:std/format | |
:std/sugar) | |
;; TODO: Add module level definition for the default delimiter | |
;; to avoid repitition and facilitate maintenance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; quasistring.ss | |
(import :std/format | |
:std/net/request) | |
;; variant: return procedure of n args? | |
(defsyntax (quasistring stx) | |
(syntax-case stx () | |
((macro s) | |
(stx-string? #'s) |
OlderNewer