我试图编写Lp范数函数来推广使用的标准L2范数(欧几里得距离)。以下是我想出了到目前为止,鉴于我是如何写的L2标准:编写Lp范数函数
(defn foo [a b p]
(reduce + (map (comp (map #(power a %) p) -) a b)))
但是我得到的错误ClassCastException异常每当我试图实现这个功能。临时代码的一部分是从那里提供了下面的代码之前问的问题Raising elements in a vector to a power:
(defn compute [exp numbers]
(map #(power exp %) numbers))