Could APL be implemented in Scala as a DSL?
문제
There is a old computer language called APL. Could this be implemented in Scala as a DSL?
해결책
Someone could probably give a better answer than this, but this is my initial thought:
A Scala DSL should in theory be able to implement any programming language because it could build up an arbitrary structure representing the syntax, and then evaluate that.
A Scala DSL could not exactly replicate APL syntax for many reasons, one of which is that
'single quotes'
can denote a string in APL, but not in Scala. Also (from the wikipedia page)
×/2 3 4
wouldn't be valid Scala.
I don't know how close you could get, though...
다른 팁
A Javascript implementation exists here: https://github.com/ngn/apl
제휴하지 않습니다 StackOverflow