Technology

Apply a Function to an Array (List): Maxima


One of the things that I always need to do when I use Maxima (the CAS system, not the car) is apply a function to every item in a list (array). Well, here’s how using the map function:

a: [1, 2, 3, 4, 5];
f(x):=x^2;
map(f,a);

Output:
[1,2,3,4,5]
f(x):=x^2
[1,4,9,16,25]

Leave a comment