kcrisman wrote: > > On Dec 14, 9:19 am, Carlos Córdoba <ccordob...@gmail.com> wrote: >> I don't think it would be so hard to do but this could break >> interoperability with Python, the language on which Sage is based. Besides >> it could make Sage like a dialect of python, something that sage devs don't >> want to do. >> >> Unfortunately python is not a very friendly functional programming >> language, although it has some constructs that can help you if you like to >> do things in the functional style. >> >> Hope this helps, >> Carlos >> >> 2009/12/13 Alasdair <amc...@gmail.com> >> >> >> >>> In some CAS's (Sage, Maxima), the "lambda" construct is used for an >>> anonymous function: >>> p=prime_range(30) >>> map(lambda x:x^2+1,p) >>> whereas in others, an arrow notation is used: >>> map(x->x^2+1,p) (Maple, MuPAD) >>> map(x+->x^2+1,p) (Axiom) >>> I'm very fond of the convenience of arrow notation. Would it be very >>> hard to incorporate such a notation into the Sage parser? > > If this would cause a Python syntax error, then presumably foo -> bar > could be turned into lambda foo: bar, which would be completely > native. Perhaps someone who is quite familiar with the preparser will > comment. But this seems like a reasonable thing to add, particularly > for those coming from Maple. What does Mathematica do for such > anonymous functions (if anything)?
#^2+1 & (note the & is important; it says what comes before is an anonymous function). Or: #1^2+#2^3 & (meaning lambda x,y: x^2+y^2). #n means the nth parameter. See the bottom of http://reference.wolfram.com/mathematica/tutorial/PureFunctions.html Jason -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org