RosettaCodeData/Task/Create-a-two-dimensional-array-at-runtime/Racket/create-a-two-dimensional-array-at-runtime.rkt
Ingy döt Net 6f050a029e update
2013-06-05 21:47:54 +00:00

12 lines
371 B
Racket

#lang racket
(printf "Enter XY dimensions: ")
(define xy (cons (read) (read)))
(define array (for/vector ([x (car xy)]) (for/vector ([y (cdr xy)]) 0)))
(printf "Enter a number for the top-left: ")
(vector-set! (vector-ref array 0) 0 (read))
(printf "Enter a number for the bottom-right: ")
(vector-set! (vector-ref array (sub1 (car xy))) (sub1 (cdr xy)) (read))
array