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)?


It looks like -> might cause a syntax error, at least in a trivial case:

sage: x -> x^2
------------------------------------------------------------
    File "<ipython console>", line 1
      x -> x**Integer(2)
         ^
SyntaxError: invalid syntax


We currently print out things in sort of functional notation:

sage: f(x)=x^2
sage: f
x |--> x^2

I don't know if it's a good idea to make this valid Sage syntax, though. 
    I'm on the fence, but leaning towards not favoring it just because 
of the added complexity and the departure from true Python, and the 
python version isn't all that bad.

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

Reply via email to