Eric Radman : a Journal

List Operations in Six Languages

map

# rb
[62, 50, 222].map {|x| x / 255.0}
=> [0.243137254901961, 0.196078431372549, 0.870588235294118]
# py
map(lambda x: x / 255.0, [62, 50, 222])
[0.24313725490196078, 0.19607843137254902, 0.87058823529411766]
; clj
(map (fn [x] (/ x 255.0)) [62 50 222])
(0.24313725490196078 0.19607843137254902 0.8705882352941177)
(* ml *)
List.map (fun x -> float_of_int x /. 255.0) [62; 50; 222;];;
- : float list = [0.243137254901960781; 0.196078431372549017; 0.870588235294117663]
-- hs
map (/ 255) [62, 50, 222]
[0.24313725490196078,0.19607843137254902,0.8705882352941177]
# pl
foreach (map {$_ / 255} (62, 50, 222)) { print "$_ "; }
0.243137254901961 0.196078431372549 0.870588235294118

$ 2011-03-11 08:44:07 -0500 $