i want make array 1xn, n maximum value occurs in input array (which contain integers). checked type of get-max sample input array below. type integer. (note, describe library (planet williams/describe/describe)))
>> (describe (array-ref (array-axis-max 0) #())) 6 byte (i.e., exact positive integer fixnum between 0 , 255 inclusive) 6
here's code produce array:
(define (array-from-max input) (local ((define get-max (array-ref (array-axis-max input 0) #()))) (make-array #(get-max) 0)))
however, following call yields error below it. make-array expects integer given 'get-max.
question 1: passing symbol-value make-array?
question 2: how can pass result of (array-axis-max) size argument of (make-array)?
question 3: what's inside #() evaluated? how evaluated?
>> (array-from-max (array #[3 6 4 1 3 4 1 4])) make-array: contract violation expected: integer given: 'get-max in: element of 1st argument of (-> (vectorof integer) any/c (struct/c array (vectorof index) any/c (box/c (or/c #f #t)) (-> any) (-> (vectorof index) any)))
question 1: yep, jack said above. #
"
strings -- once you're inside, characters taken literally.
question 2: use (vector get-max)
. here's example
#lang racket (require math/array) (define (array-from-max input) (local ((define get-max (array-ref (array-axis-max input 0) #()))) (make-array (vector get-max) 0))) (array-from-max (array #[3 6 4 1 3 4 1 4]))
question 3: things inside #()
automatically quoted, specified in vectors racket guide
Comments
Post a Comment