A macro for pretty geometric algebra equations?

The following macro to give the option of writing geometric algebra equations using “standard” math syntax operators instead of “standard” programming syntax operators is good enough for me for now:

# convert GA math syntax to GA programming syntax
macro ga_str(str)
	C = collect(str)
	n = length(C)
	for i = 1:n
		if C[i] == ' '		# \thinspace for geometric product
			C[i] = '*'
		elseif C[i] == '∧'	# \wedge for outer product
			C[i] = '^'
		elseif C[i] == '∨'	# \vee for regressive product
			C[i] = '&'
		elseif C[i] == '·'	# \cdotp for inner product
			C[i] = '|'
		elseif C[i] == '\u20f0'	# \asteraccent for dual
			j = i-1
			while j > 0 # shift operator from postfix to prefix
				if isletter(C[j]) || isnumeric(C[j])
					C[j+1] = C[j]
					j -= 1
				else
					break
				end
			end
			C[j+1] = '!' # prefix '!'
		end
	end
	return esc(Meta.parse(String(C)))
end

The macro’s translation from math syntax to programming syntax slowed my unit test down by just 2.5% (4.69 us versus 4.58 us, according to @btime utest(false)).

I’m not yet sure if I will implement the translation for the sandwich operator because I am content with the look and speed of the geometric product operator and the tilde (i.e., reverse) operator implementing the sandwich operation.

Next week’s task: integrating the Julia reference implementation of projective geometric algebra with the interactive graphics of Makie.

Thanks for the help and the feedback.