Racket 球拍中违反合同(制作阵列)

Racket 球拍中违反合同(制作阵列),racket,Racket,我想制作一个1xn的数组,其中n是某个输入数组中出现的最大值(它只包含整数)。 我用下面的示例输入数组检查了get max的类型。它的类型是整数。(注意,描述来自图书馆(planet williams/descripe/descripe))) 以下是生成数组的代码: (define (array-from-max input) (local ((define get-max (array-ref (array-axis-max input 0) #()))) (make-array

我想制作一个1xn的数组,其中n是某个输入数组中出现的最大值(它只包含整数)。 我用下面的示例输入数组检查了get max的类型。它的类型是整数。(注意,描述来自图书馆(planet williams/descripe/descripe)))

以下是生成数组的代码:

(define (array-from-max input)
  (local ((define get-max (array-ref (array-axis-max input 0) #())))
    (make-array #(get-max) 0)))
但是,下面的调用会产生下面的错误。make数组需要一个整数,但被指定为“get-max”

问题1:我真的要将符号值传递到make数组中吗

问题2:如何将(array axis max)的结果成功传递到(make array)的size参数中

问题3:#()内部的内容是否经过评估?如何评估

>> (array-from-max (array #[3 6 4 1 3 4 1 4]))
make-array: contract violation
  expected: Integer
  given: 'get-max
  in: an element of
      the 1st argument of
      (->
       (vectorof Integer)
       any/c
       (struct/c
        Array
        (vectorof Index)
        any/c
        (box/c (or/c #f #t))
        (-> any)
        (-> (vectorof Index) any)))

问题1:是的,就像杰克上面说的。
#
类似于字符串的
——一旦进入,字符就会被逐字提取

问题2:使用
(vector get max)
。下面是一个示例

#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]))

问题3:
#()
中的内容会自动被引用,如《球拍指南》中所述。注意,我确实知道有人问了很多违反合同的球拍问题,但我无法找到/识别哪一个问题适用于这里。#(…)是文本向量的读取器语法,类似于“(…)是一个文字列表。文字中的任何内容都假定为文字,因此#(foo)生成一个包含符号“foo”的向量,而不是一个包含名为foo的变量值的向量,方式与“(foo)相同生成一个带有符号foo的列表。由于我无法再现您的错误,所以不会将此作为答案发布-我在
(array axis max input 0)
中遇到了一些奇怪的多态类型检查错误。
#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]))