Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
 Summary Activity SCM

# SCM Repository

[sml3d] Annotation of /src/common/vec4.sml
 [sml3d] / src / common / vec4.sml

# Annotation of /src/common/vec4.sml

Revision 37 - (view) (download)

 1 : jhr 14 (* vec4.sml 2 : * 3 : * COPYRIGHT (c) 2008 John Reppy (http://www.cs.uchicago.edu/~jhr) 4 : * All rights reserved. 5 : * 6 : * Some common structural operations on 4-element vectors. 7 : *) 8 : 9 : structure Vec4 = 10 : struct 11 : 12 : fun unpack {x, y, z, w} = (x, y, z, w) 13 : fun pack (x, y, z, w) = {x=x, y=y, z=z, w=w} 14 : fun toList {x, y, z, w} = [x, y, z, w] 15 : 16 : fun setX ({x, y, z, w}, v) = {x=v, y=y, z=z, w=w} 17 : fun setY ({x, y, z, w}, v) = {x=x, y=v, z=z, w=w} 18 : fun setZ ({x, y, z, w}, v) = {x=x, y=y, z=v, w=w} 19 : fun setW ({x, y, z, w}, v) = {x=x, y=y, z=w, w=v} 20 : 21 : fun nth ({x, y, z, w}, 0) = x 22 : | nth ({x, y, z, w}, 1) = y 23 : | nth ({x, y, z, w}, 2) = z 24 : | nth ({x, y, z, w}, 3) = w 25 : | nth _ = raise Subscript 26 : 27 : (* iterators *) 28 : fun map f {x, y, z, w} = {x = f x, y = f y, z = f z, w = f w} 29 : jhr 37 fun app (f : 'a -> unit) {x, y, z, w} = (f x; f y; f z; f w) 30 : jhr 14 31 : end

 root@smlnj-gforge.cs.uchicago.edu ViewVC Help Powered by ViewVC 1.0.0