| 1 | (******************************************************************************* |
|---|
| 2 | Copyright 2009 Sun Microsystems, Inc., |
|---|
| 3 | 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
|---|
| 4 | All rights reserved. |
|---|
| 5 | |
|---|
| 6 | U.S. Government Rights - Commercial software. |
|---|
| 7 | Government users are subject to the Sun Microsystems, Inc. standard |
|---|
| 8 | license agreement and applicable provisions of the FAR and its supplements. |
|---|
| 9 | |
|---|
| 10 | Use is subject to license terms. |
|---|
| 11 | |
|---|
| 12 | This distribution may include materials developed by third parties. |
|---|
| 13 | |
|---|
| 14 | Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered |
|---|
| 15 | trademarks of Sun Microsystems, Inc. in the U.S. and other countries. |
|---|
| 16 | ******************************************************************************) |
|---|
| 17 | |
|---|
| 18 | component comprehensions |
|---|
| 19 | import Set.{...} |
|---|
| 20 | import List.{...} |
|---|
| 21 | import Map.{...} |
|---|
| 22 | export Executable |
|---|
| 23 | |
|---|
| 24 | run():() = () |
|---|
| 25 | |
|---|
| 26 | set_comp_one = { i + j | i <- 1 # 10 , j <- 0 # 1 } |
|---|
| 27 | set_comp_two = {a^b | a<-2#2,b<-1#4} |
|---|
| 28 | set_comp_tri = { i+j | i <- 1#10, j <- 1#10, i < j } |
|---|
| 29 | |
|---|
| 30 | list_comp_one = <| i + j | i <- 1 # 10 , j <- 0 # 1 |> |
|---|
| 31 | list_comp_two = <|a^b | a<-2#2,b<-1#4|> |
|---|
| 32 | |
|---|
| 33 | map_comp_one = { i - j |-> j - i | i <- 1 # 10 , j <- 1 # 1 } |
|---|
| 34 | map_comp_two = {a^b|->a b | a<-2#2,b<-1#4} |
|---|
| 35 | |
|---|
| 36 | array_comp_big = [ (x,y,1) |-> 0.0 | x <- 1#xSize, y <- 1#ySize |
|---|
| 37 | (1,y,z) |-> 0.0 | y <- 1#ySize, z <- 2#zSize |
|---|
| 38 | (x,1,z) |-> 0.0 | x <- 2#xSize, z <- 2#zSize |
|---|
| 39 | (x,y,z) |-> x + y z | x <- 2#xSize, |
|---|
| 40 | y <- 2#ySize, |
|---|
| 41 | z <- 2#zSize ] |
|---|
| 42 | end |
|---|