TL DR:
Why does this work: ex = :(X --> Y)
but not this: ex = :(X <--> Y)
Longer description:
I work with biochemical reaction systems and I want to create a macro into which I can type the reactions and which the generates the differential equations for me, to be solved using DifferentialEquations.jl.
DifferentialEquations.jl already have a macro for this:
rs = @reaction_network begin
2.0, X --> Y
1.0, Y --> X
end
However since most of my reactions go in both directions I would want do be able to do something like:
rs = @reaction_network begin
(1.0,2.0), X <--> Y
end
this would make a lot of things half as long. In addition I would like to have functionality to put in more things as reaction rates (pre declared constants, or function of the reactant concentrations. This way I could allow to have reactions with rates not necessarily linear to the reactants concentration).
Since DifferentialEquations.jl have a very similar function I decided it would probably be a task suited for a macro and have been reading up on them. However it seems like I cannot create expressions using <---> (to denote a two way reactions), and I have been unable to understand what’s the difference between
ex = :(X --> Y)
ex = :(X <--> Y)
Neither expression is valid Julia code to begin with, but what trait of the one way arrow makes it allowed, as opposite to the two way arrow?
It depends on whether Julia can parse it, and indeed the way to find out is to try to make an expression. There are a bunch of unicode operatores, which probably include all sorts of arrows, maybe that could be for you?
Thank you, this works very well. Just one small thing:
First I tried ↔ and it worked very well
ex = :(X ↔ Y)
However then I discovered that their also was the ⇄ arrows which are more common in chemical reactions, so I figured I might use them. However when I write:
ex = :(X ⇄ Y)
I get the error
“syntax: missing comma or ) in argument list”
On closer inspection I get that very same error whenever I use one of the errors subsequent to the → arrow in the list you gave
(That is the arrows ⇜ ⇝ ↜ ↝ ↩ ↪ ↫ ↬ ↼ ↽ ⇀ ⇁ ⇄ ⇆ ⇇ ⇉ ⇋ ⇌ ⇚ ⇛ ⇠ ⇢ generates errors, but all others works fine). Now it will not be a major problem to use ↔ instead of ⇄, however I am curious of what this issue is about?
cheers