running mathics in pure python

47 views
Skip to first unread message

Arihant Parsoya

unread,
Mar 27, 2017, 11:51:05 AM3/27/17
to mathics-devel
Hi,

I have been using Mathics for quite some time now on my local server. I wanted to know if its possible to run mathics using pure python. I have seen that tests for Mathics are written in python. However, it will be quite useful if someone can give an example on how to debug this Mathics example in python:

    >> a+b+c /. c->d
    = a + b + d

    >> Replace[1 + x, {x -> 2}]
     = 1 + x

Thanks,
Arihant Parsoya

Angus Griffith

unread,
Mar 29, 2017, 1:55:48 AM3/29/17
to mathic...@googlegroups.com
Hi Arihant,

I'm a bit confused by your question. Mathics is written is pure python (although you can compile the core with cython).

I think the confusion is coming from the difference between Replace and ReplaceAll (/. notation). Replace only applies to full expressions

In[1]:= Replace[x, {x->2}]
Out[1]= 2

In[2]:= Replace[x^2, {x->2}]
Out[2]= x ^ 2

ReplaceAll however applies at all levels:

In[3]:= ReplaceAll[1 + x, {x->2}]
Out[3]= 3

In[4]:= (1 + x) /. {x->2}
Out[4]= 3


Thanks,
Angus


--
You received this message because you are subscribed to the Google Groups "mathics-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathics-devel+unsubscribe@googlegroups.com.
To post to this group, send email to mathic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathics-devel/5919cc9d-3521-474e-ad31-f565c33657e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages