Navigation
Synopsis Compute the product of two lists.
Syntax Exp1 * Exp2
Types
Exp1 Exp2 Exp1 * Exp2
list[T1] list[T2] list[tuple[T1,T2]]
Description Yields a list of tuples resulting from the product of the values of Exp1 and Exp2. It contains a tuple for each combination of values from both arguments.
Examples
rascal>[1, 2, 3] * [4, 5, 6];
lrel[int,int]: [
  <1,4>,
  <1,5>,
  <1,6>,
  <2,4>,
  <2,5>,
  <2,6>,
  <3,4>,
  <3,5>,
  <3,6>
]
Here is a concise way to create a deck of cards:
rascal>["clubs", "hearts", "diamonds", "spades"] * [1 .. 13];
lrel[str,int]: [
  <"clubs",1>,
  <"clubs",2>,
  <"clubs",3>,
  <"clubs",4>,
  <"clubs",5>,
  <"clubs",6>,
  <"clubs",7>,
  <"clubs",8>,
  <"clubs",9>,
  <"clubs",10>,
  <"clubs",11>,
  <"clubs",12>,
  <"hearts",1>,
  <"hearts",2>,
  <"hearts",3>,
  <"hearts",4>,
  <"hearts",5>,
  <"hearts",6>,
  <"hearts",7>,
  <"hearts",8>,
  <"hearts",9>,
  <"hearts",10>,
  <"hearts",11>,
  <"hearts",12>,
  <"diamonds",1>,
  <"diamonds",2>,
  <"diamonds",3>,
  <"diamonds",4>,
  <"diamonds",5>,
  <"diamonds",6>,
  <"diamonds",7>,
  <"diamonds",8>,
  <"diamonds",9>,
  <"diamonds",10>,
  <"diamonds",11>,
  <"diamonds",12>,
  <"spades",1>,
  <"spades",2>,
  <"spades",3>,
  <"spades",4>,
  <"spades",5>,
  <"spades",6>,
  <"spades",7>,
  <"spades",8>,
  <"spades",9>,
  <"spades",10>,
  <"spades",11>,
  <"spades",12>
]

Questions
Question [1]. When you compute the product of two lists, the number of elements in the result is always:




Question [2].
The type of ["Pineapple"] * ["Big Bird"] is

Question [3].
[8] * [29] == 

Question [4].
[25] * [33, 40] == 

Question [5].
size([6, 48] * [28, 41, 17]) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.