娱乐帖:小区电梯长宽都是1.3米,能否载得下1.8米的床垫?
Scala:
scala> import scala.math._
import scala.math._
scala> def mlen(x: Double, y: Double) = sqrt(pow(x, 2) + pow(y, 2))
mlen: (x: Double,y: Double)Double
scala> mlen(1.3, 1.3)
res0: Double = 1.8384776310850237
Clojure :
user=> (ns user (use clojure.contrib.math))
nil
user=> (sqrt 1.3)
1.140175425099138
user=> (defn xlen [x y] (sqrt (+ (* x x) (* y y))))
#'user/xlen
user=> (xlen 1.3 1.3)
1.8384776310850237
user=>
1.83 米啊, 勉强,也够呛。
scala> import scala.math._
import scala.math._
scala> def mlen(x: Double, y: Double) = sqrt(pow(x, 2) + pow(y, 2))
mlen: (x: Double,y: Double)Double
scala> mlen(1.3, 1.3)
res0: Double = 1.8384776310850237
Clojure :
user=> (ns user (use clojure.contrib.math))
nil
user=> (sqrt 1.3)
1.140175425099138
user=> (defn xlen [x y] (sqrt (+ (* x x) (* y y))))
#'user/xlen
user=> (xlen 1.3 1.3)
1.8384776310850237
user=>
1.83 米啊, 勉强,也够呛。