Suggestions on syntax to express mathematical formula concisely

前端 未结 13 1145
予麋鹿
予麋鹿 2021-02-02 08:46

I am developing functional domain specific embedded language within C++ to translate formulas into working code as concisely and accurately as possible.

I posted a proto

13条回答
  •  遇见更好的自我
    2021-02-02 09:12

    I'm not familiar with Phoenix and can only make assumptions about it's capabilities.

    I've always liked the way Haskell allows me to express ranges as a list comprehension. It translates nicely from the actual mathematical notation into the programming language construct.

    [ i + j | i <- [1..10], j <- [1..10] ]
    

    would end up as something like:

    [ i + j | i = range(1,10), j = range(1,10) ]
    

    Unfortunately I really don't know if something like this is even possible with Phoenix.

提交回复
热议问题