'Maxima: Rounding the entries of a list using Robert Dodier's excel_round.mac

I want the entries of a Maxima list to be rounded in Excel style using Robert Dodier's excel_round.mac (see Maxima: Round like in Excel) on the fly.

I created a list, say the values of exp(0.5*x) over the range from [-2,2].

(%i1)  makelist(exp(0.5*x),x,-2,2)$
       soln: %
(%o1) [0.36788,0.60653,1,1.6487,2.7183]

The problem I'm having is how to get all the list entries into the x of below.

(%i1)  excel_round(x,2)$
       ev(%, x=?)   

As trying the following

(%i2)  map(exel_round(x,2),soln);       
(%o2)  [exel_round(x,2)(0.36788),exel_round(x,2)(0.60653),  
       exel_round(x,2)(1),exel_round(x,2)(1.6487),exel_round(x,2)(2.7183)]

and

(%i12)  makelist(exp(0.5*x),x,-2,2);  
        soln: %$
        excel_round(x,2)$  
        ev(%, x=soln)
(%o12)  [0.36788,0.60653,1,1.6487,2.7183]  
(%o15)  excel_round([0.36788,0.60653,1,1.6487,2.7183],2)

didn't yield the desired results I returned to semi-brute force:

(%i18)  excel_round(x,2)$
            ev(%, x=soln[1]);
        excel_round(x,2)$
            ev(%, x=soln[2]);  
        excel_round(x,2)$  
            ev(%, x=soln[3]);  
        excel_round(x,2)$  
            ev(%, x=soln[4]);  
        excel_round(x,2)$  
            ev(%, x=soln[5])
(%o19) 0.37  
(%o21) 0.61  
(%o23) 1.0  
(%o25) 1.65  
(%o27) 2.72

This is probably better than typing in all the list entries by hand. There surely must be a better and more elegant way.

Any help/suggestions welcome.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source