JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.52k stars 5.46k forks source link

RFC: Symbolic computation in Julia #9896

Closed jlapeyre closed 9 years ago

jlapeyre commented 9 years ago

The main content of this post is not about Julia itself, although a few issues that might change Julia do arise. I think Julia+ecosystem is the best choice for implementing a powerful symbolic manipulation engine. I've done some experiments and any feedback on implementation or design is welcome. Here is the code https://github.com/jlapeyre/SJulia. And there is a repl available if you build this fork of Julia https://github.com/jlapeyre/julia/tree/jl/symrepl . But it is not necessary. Here is an example of what I am talking about.

sjulia> ClearAll(fib)
sjulia> fib(1) := 1
sjulia> fib(2) := 1
sjulia> fib(n_) := fib(n-1) + fib(n-2)
sjulia> fib(10)
55

This looks like all the others, of course. But, the interesting thing is how it is implemented. It is implemented in the same way that this is.

sjulia> f(x_) := x^2
sjulia> f(a+b)
(a+b)^2

--John

StefanKarpinski commented 9 years ago

Cool stuff. This seems more apt for a julia-users post than a GitHub issue.

jlapeyre commented 9 years ago

Yes, that's probably right. I put the caveat at the top to be clear. I was looking for input from people with experience with language design. But, broadening the audience is not a bad idea. I'll post it on julia-users.