In Lisp, how many inputs can the + function actually have?

后端 未结 5 1295
走了就别回头了
走了就别回头了 2020-12-18 04:02

I\'m relatively new to Lisp, and I was wondering if there really is an upper limit to the \"+\" function.

(I guess this applies to all the other arithmetic function

5条回答
  •  星月不相逢
    2020-12-18 04:47

    It depends of the implementation. "I would suggest LISP users take 5 minutes to test their platform".

    For Clojure

    (defn find-max-n [n]
      (try 
        (eval (concat (list +) (take n (repeat 1))))
        (println "more than" n)
        ; return n if something goes wrong
        (catch Exception e n))
      (recur (* n 2)))
    
    
    (find-max-n 1)
    

    It doesn't terminate, it hangs at 8192 given my settings.

    more than 1
    more than 2
    more than 4
    more than 8
    more than 16
    more than 32
    more than 64
    more than 128
    more than 256
    more than 512
    more than 1024
    more than 2048
    more than 4096
    more than 8192
    

提交回复
热议问题