2014-04-29 23 views

回答

3

只需使用numeratordenominator功能。

> (numerator (/ 2 3)) 
2 
> (denominator (/ 2 3)) 
3 
> 
+0

非常感謝您,+1 –

2

使用分子和分母的功能,以提取數字對象這樣

(defn ratio-to-vector [r] 
((juxt numerator denominator) r)) 

例如

(比例 - 矢量22/7); => [22 7]

請注意,在這種形式下,函數將打破其他數值類型。

+0

非常感謝你,+1 –