gpt4 book ai didi

math - 为什么 clojure 返回 1N 而不是 1?

转载 作者:行者123 更新时间:2023-12-02 22:34:54 27 4
gpt4 key购买 nike

;; ------------------------- DICE COEFFS ------------------------

(defn dice-set-coeff [a b]
(* (/ (count (clojure.set/intersection a b))
(+ (count a) (count b)))
2))

(defn dice-lst-coeff [a b]
(dice-set-coeff (set a) (set b)))

;; ------------------------- BIGRAMS ----------------------------

(defn now-nxt [xs]
"im sure there is a better way to write this"
(map #(list %1 %2) xs (rest xs)))

(defn bigram [xs]
(list now-nxt xs))

(defn dice-string-bigram [a b]
(dice-lst-coeff (bigram a) (bigram b)))

为什么我在结果中得到 1N?

tst.core> (dice-string-bigram "hello" "hello")
1N
tst.core> (dice-string-bigram "hello" "helap")
1/2
tst.core> (dice-string-bigram "hello" "howdy")
0
tst.core> (== (dice-string-bigram "hello" "hello") 1)
true

最佳答案

1N 是读者和 REPL 用于 BigInts 的语法。

其中一个调用正在返回一个 bigint。


回复:“我确定有更好的方法来写这个”

user> (now-nxt a)
((\h \e) (\e \l) (\l \l) (\l \o))
user> (partition 2 1 a)
((\h \e) (\e \l) (\l \l) (\l \o))

关于math - 为什么 clojure 返回 1N 而不是 1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11603804/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com