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 (prime n) | |
(let loop ((lst (iota (- n 1) 2))(result '())) | |
(let ((solve (cons (car lst) result))) | |
(if (< (last lst) (* (car solve) (car solve))) | |
(append (reverse result) lst) | |
(loop (remove (^(x)(zero? (remainder x (car lst)))) lst) solve))))) |
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 (sieve 10000)) | |
; real 0.055 | |
; user 0.060 | |
; sys 0.000 | |
;(time (piota 10000)) | |
; real 0.009 | |
; user 0.010 | |
; sys 0.000 |
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 fizzbuzz '(1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizzbuzz)) | |
(define (solve n) | |
(let loop ((num 1)(lst fizzbuzz)(m 1)) | |
(cond | |
((null? lst) | |
(loop num (map (lambda(x)(if (number? x)(+ x (* 15 m)) x)) fizzbuzz) (+ m 1))) | |
((>= n num) | |
(print (car lst)) | |
(loop (+ num 1) (cdr lst) m))))) |
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 base (string->list "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) | |
(define base2 (string->list "abcdefghijklmnopqrstuvwxyz")) | |
(define (caesar lst n) | |
(let ((solve (append (drop base n) (take base n))) | |
(solve2 (append (drop base2 n) (take base2 n)))) | |
(let loop ((lst lst) | |
(n 0) | |
(result '())) | |
(cond |
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
(use srfi-42) | |
(define strl '(fizz buzz fizz fizz buzz fizz fizzbuzz)) | |
(define intl '(3 5 6 9 10 12 15)) | |
(define (min-list lst) | |
(let loop ((ls (map (lambda(x)(length x)) lst)) | |
(n 0)) | |
(if (eq? (car ls) (apply min ls)) | |
n |
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
(filter (lambda(x)x)(list-ec (: m 1 (+ 100 1))(and(equal? (filter (lambda(x)x) (list-ec (: x 1 (+ m 1))(and (= (mod m x) 0) x))) (list 1 m))m))) |
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 (position key lst) | |
(let loop ((lst lst)(n 0)(result '())) | |
(cond | |
((null? lst) (reverse result)) | |
((eq? key (car lst))(loop (cdr lst) (+ n 1) (cons n result))) | |
(else (loop (cdr lst) (+ n 1) result))))) |
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
#!/usr/local/bin/gosh | |
(use srfi-27) | |
(define *board* (make-vector 9 'empty)) | |
(define (board-ref n)(vector-ref *board* n)) | |
(define (board-set! n m)(vector-set! *board* n m)) | |
(define (print-board) | |
(let ((lst '((maru . "◯") (batu . "×") (empty . ".")))) | |
(dotimes (x 9) | |
(format #t "~A " (cdr (assq (vector-ref *board* x) lst))) |
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
#!/usr/local/bin/gosh | |
(define (cows data ans) | |
(let loop ((ans ans)(count 0)) | |
(cond ((null? ans)count) | |
((member (car ans) data) | |
(loop (cdr ans) (+ count 1))) | |
(else (loop (cdr ans) count))))) | |
(define (bulls data ans) |
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
#!/usr/local/bin/gosh | |
(use gl) | |
(use gl.glut) | |
(define (draw_cube) | |
(let1 vert '#( | |
(1.0 1.0 1.0) | |
(-1.0 1.0 1.0) | |
(-1.0 -1.0 1.0) | |
(1.0 -1.0 1.0) | |
(1.0 1.0 -1.0) |
NewerOlder