Dyalog APL 中的“APL 对象符号”

Ole*_*exa 5 apl dyalog

如何将任何 Dyalog APL 值转换为可以传递给以?获得相同值的字符向量?

预期的样子:

      x?2 3??6
      x?1,?x
      x?x,?'foo'
      y?desired_function x
      DPX y
????????????????????
?1,(?2 3??6),?'foo'?
????????????????????
      x??y
1
Run Code Online (Sandbox Code Playgroud)

更新

这个想法是将一个值转换为人工可编辑的 APL 源代码,以便在发现新的有问题的场景时能够将其插入到单元测试函数中。我希望这些测试场景在 APL 源代码中,而不是在文件中,因为在我使用的框架中,源代码由版本控制系统很好地管理,而文件则不是。而且我希望它是可人工编辑的,而不仅仅是序列化,以便在参数/结果发生变化时更容易修改现有的测试场景。

Jür*_*ann 1

不确定 Dyalog APL,但大多数其他 APL 都有内置函数来实现这一点。

\n\n

在 IBM APL2 中(因此也在 GNU APL 中),您可以使用2 \xe2\x8e\x95TF在值(实际上是具有该值的变量)和生成它的 APL 代码之间进行转换(尽管不是通过\xe2\x8d\x8e但通过另一个2 \xe2\x8e\x95TF):

\n\n
      4 \xe2\x8e\x95CR x\n\xe2\x94\x8f\xe2\x86\x92\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x93\n\xe2\x94\x831 \xe2\x94\x8f\xe2\x86\x92\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x93 \xe2\x94\x8f\xe2\x86\x92\xe2\x94\x81\xe2\x94\x81\xe2\x94\x93\xe2\x94\x83\n\xe2\x94\x83  \xe2\x86\x931 2 3\xe2\x94\x83 \xe2\x94\x83foo\xe2\x94\x83\xe2\x94\x83\n\xe2\x94\x83  \xe2\x94\x834 5 6\xe2\x94\x83 \xe2\x94\x97\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x9b\xe2\x94\x83\n\xe2\x94\x83  \xe2\x94\x97\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x9b      \xe2\x94\x83\n\xe2\x94\x97\xe2\x88\x8a\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x9b\n\n\n      \xe2\x8e\x95\xe2\x86\x90text\xe2\x86\x902 \xe2\x8e\x95TF 'x'\nx\xe2\x86\x901 (2 3\xe2\x8d\xb41 2 3 4 5 6) 'foo'\n\n      )erase x\n      2 \xe2\x8e\x95TF text\nx\n      4 \xe2\x8e\x95CR x\n\xe2\x94\x8f\xe2\x86\x92\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x93\n\xe2\x94\x831 \xe2\x94\x8f\xe2\x86\x92\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x93 \xe2\x94\x8f\xe2\x86\x92\xe2\x94\x81\xe2\x94\x81\xe2\x94\x93\xe2\x94\x83\n\xe2\x94\x83  \xe2\x86\x931 2 3\xe2\x94\x83 \xe2\x94\x83foo\xe2\x94\x83\xe2\x94\x83\n\xe2\x94\x83  \xe2\x94\x834 5 6\xe2\x94\x83 \xe2\x94\x97\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x9b\xe2\x94\x83\n\xe2\x94\x83  \xe2\x94\x97\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x9b      \xe2\x94\x83\n\xe2\x94\x97\xe2\x88\x8a\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x81\xe2\x94\x9b\n
Run Code Online (Sandbox Code Playgroud)\n\n

在 GNU APL 中,您还可以使用10 \xe2\x8e\x95CR来实现此目的。结果由多个 APL 语句组成,因此您必须对结果进行\xe2\x8d\x8e\xc2\xa8 :

\n\n
      10 \xe2\x8e\x95CR 'x'\n x\xe2\x86\x901 00 00   ((\xe2\x8e\x95IO+1)\xe2\x8a\x83x)\xe2\x86\x902 3\xe2\x8d\xb41 2 3 4 5 6   ((\xe2\x8e\x95IO+2)\xe2\x8a\x83x)\xe2\x86\x90'foo' \n\n      \xe2\x8a\x8310 \xe2\x8e\x95CR 'x'\n    x\xe2\x86\x901 00 00                    \n      ((\xe2\x8e\x95IO+1)\xe2\x8a\x83x)\xe2\x86\x902 3\xe2\x8d\xb41 2 3 4 5 6\n      ((\xe2\x8e\x95IO+2)\xe2\x8a\x83x)\xe2\x86\x90'foo'          \n
Run Code Online (Sandbox Code Playgroud)\n