5. lambda expression
alist: [8, 5, 2, 4, 62, 4, 6]
anOp: blablabla
apply the operation to the list.
like:
for i = 0 to len(alist):
anOp( alist[i] )
or:
foreach i in alist:
anOp( i )
6. Implement
apply_square_for_each(alist):
foreach i in alist: square( i );
apply_plusplus7_for_each(alist):
foreach i in alist: plusplus7( i );
apply_for_each(alist, op):
case
when op == "square":
foreach i in alist: square( i )
.....
8. General LISt Processing
Map :
[x,y,z] -> map(op,[x,y,z])
=> [op(x),op(y),op(z)]
Reduce :
[x,y,z] -> reduce(op,[x,y,z],v)
=> op(op(op(v,x),y),z)
Filter :
[x,y,z] -> filter(op,[x,y,z])
=> a subset of the list for each
op(i) => true