Thanks BP, now map works with functions of more than two arguments, but when iterating over a set, the set prefix is lost, please improve this case.
Code : Tout sélectionner
map( normal, set( [ (x-1)*(x+1) , x² - 1 ] ) ) // returns [x^2-1,x^2-1] should return set[x^2-1, x^2-1]
eval( set[x^2-1, x^2-1]) -> set[x^2-1]
also if the argument is a matrix of a row, work in pairs
Code : Tout sélectionner
sumxy( x, y ):= return x + y;
map( sumxy, [[ 1, 2, 3, 4 ]], matrix ) //-> [[ 1+2->3, 3+4 ]] -> [[3, 7]]
map( sumxy, matrix[[ 1, 2, 3, 4 ]] ) /
Xcas session
https://www.eonicasys.com/CAS/xcas/casc ... as_eng.xws
/* map cmd */
autosimplify( false )
multiply2( x ):= return x * 2
map( multiply2, [ 1, 2, 3, 4 ] )
sumxy( x, y ):= return x + y
map( sumxy, [ 1, 2 ], [ 3, 4 ] )
map( sumxy, [[ 1, 2, 3, 4 ]], matrix ) //-> [[ 1+2->3, 3+4 ]] -> [[3, 7]]
list_a := [ 1, 2, 3 ];
list_b := [ 10, 20, 30 ]
map( lambda x, y: x + y, list_a, list_b )
list_c := [ -1, 1, -1 ]
map( lambda x, y, z: (x + y) * z, list_a, list_b, list_c )
solve( x^3-6*x^2+11*x = 6, x, '=' )
subst( x^3-6*x^2+11*x = 6, set[ x=1, x=2, x=3 ] )
convert( set[ x=1, x=2, x=3 ], list )
map( lambda x : subst( x^3-6*x^2+11*x = 6, x), [ x=1, x=2, x=3 ] )
map( lambda x : evalb( subst( x^3-6*x^2+11*x = 6, x)), [ x=1, x=2, x=3 ] )
map( x -> x ≥ -1 ,[ -5, -3, -1, 1 ] )
apply(x -> x >= -1,[ -5, -3, -1, 1 ] )
map(lambda x: x ≥ -1 ,[ -5, -3, -1, 1 ] )
map( propfrac, [5/3, 18229/94, 53/12 ] ) // mixed number