Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
(import (scheme base)
|
||||
(scheme read)
|
||||
(scheme write))
|
||||
|
||||
;; Read x/y from user
|
||||
(define x (begin (display "X: ") (flush-output-port) (read)))
|
||||
(define y (begin (display "Y: ") (flush-output-port) (read)))
|
||||
|
||||
;; Create a vector, and fill it with a vector for each row
|
||||
(define arr (make-vector x))
|
||||
(do ((i 0 (+ 1 i)))
|
||||
((= i x) )
|
||||
(vector-set! arr i (make-vector y 0)))
|
||||
|
||||
;; set element (x/2, y/2) to 3
|
||||
(vector-set! (vector-ref arr (floor (/ x 2)))
|
||||
(floor (/ y 2))
|
||||
3)
|
||||
|
||||
(display arr) (newline)
|
||||
(display "Retrieved: ")
|
||||
(display (vector-ref (vector-ref arr (floor (/ x 2)))
|
||||
(floor (/ y 2))))
|
||||
(newline)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
(import (except (scheme base) equal?)
|
||||
(scheme read)
|
||||
(scheme write)
|
||||
(srfi 63) ; an array SRFI
|
||||
)
|
||||
|
||||
;; Read x/y from user
|
||||
(define x (begin (display "X: ") (flush-output-port) (read)))
|
||||
(define y (begin (display "Y: ") (flush-output-port) (read)))
|
||||
|
||||
;; Create an array
|
||||
(define array (make-array #(0) x y))
|
||||
|
||||
;; Write to middle element of the array
|
||||
(array-set! array 3 (floor (/ x 2)) (floor (/ y 2)))
|
||||
|
||||
;; Retrieve and display result
|
||||
(display (array-ref array (floor (/ x 2)) (floor (/ y 2)))) (newline)
|
||||
Loading…
Add table
Add a link
Reference in a new issue