On Aug 22, 5:04 pm, Robert Dodier <[EMAIL PROTECTED]> wrote:
> William Stein wrote:
> >   sage: data = [-1, 2, 3]
> >   sage: data = ma_eval('data /. x_?(# < 0 &) -> 0')
> >   sage: data
> >   [0, 2, 3]

> Wouldn't it be much clearer, and much less hackish, to just make
> them functions and stay entirely within Python?

For me, python is a different playground than mma and unless there
isn't a real reason i don't like to import mma syntax - or any other.
Perhaps in a special mode, but that's a different setting (e.g.
providing a directory of mma .nb files (or .m for matlab/octave) and
extracting functions and evaluating them by parsing those files)

this example is for me better done by

>>> data = [-1,2,3]
>>> gt0 = lambda x: x>0 and x or 0
>>> map(gt0, data)
[0, 2, 3]

in python - or more geeky

>>> map(lambda x: x>0 and x or 0, data)
[0, 2, 3]

H
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to