# VisibleList / Function -- apply a function to elements of a list

## Synopsis

• Operator: /
• Usage:
x/f
f\x
• Inputs:
• Outputs:
• , the list, tally, or set obtained by applying f to each element of x; it has the same type as x has

## Description

The function apply does the same thing.

The operator / is left associative, which means that w / f / g is interpreted as (w / f) / g. The operator \ is right associative, so g \ f \ w is interpreted as g \ (f \ w). Both operators have parsing precedence lower than that of @@, which means that the previous two expressions are equivalent to w / g @@ f and g @@ f \ w, respectively. See precedence of operators.

 i1 : f = x -> x+1 o1 = f o1 : FunctionClosure i2 : g = x -> 2*x o2 = g o2 : FunctionClosure i3 : g \ (1 .. 10) o3 = (2, 4, 6, 8, 10, 12, 14, 16, 18, 20) o3 : Sequence i4 : (1 .. 10) / g o4 = (2, 4, 6, 8, 10, 12, 14, 16, 18, 20) o4 : Sequence i5 : f \ g \ (1 .. 10) o5 = (3, 5, 7, 9, 11, 13, 15, 17, 19, 21) o5 : Sequence i6 : f @@ g \ (1 .. 10) o6 = (3, 5, 7, 9, 11, 13, 15, 17, 19, 21) o6 : Sequence i7 : set (1 .. 10) o7 = set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} o7 : Set i8 : g \ oo o8 = set {2, 4, 6, 8, 10, 12, 14, 16, 18, 20} o8 : Set i9 : R = QQ[x]; i10 : f = map(R,R,{x^2}) 2 o10 = map (R, R, {x }) o10 : RingMap R <--- R i11 : f \ {x,x^2,x^3,x^4} 2 4 6 8 o11 = {x , x , x , x } o11 : List

## Code

../../../../../../../Macaulay2/m2/classes.m2:76:49-76:60: --source code:
VisibleList /  Function := VisibleList => (v,f) -> apply(v,f)

## Ways to use this method:

• "List / Command"
• "List / Function"
• "List / RingMap"
• "String / Command"
• "String / Function"
• "VirtualTally / Command"
• "VirtualTally / Function"
• "VisibleList / Command"
• VisibleList / Function -- apply a function to elements of a list
• "VisibleList / SelfInitializingType"