JMP Expr() 的奇怪之处,有人能解释一下吗?这主要是一篇关于将“IF”表达式插入“IF”表达式的不一致问题的令人沮丧的帖子。我的理解是,如果不一致,编程语言就毫无意义(而且我知道 JMP 的许多其他不一致之处 - 只是这一点对我来说根本没有意义)。
/*
What I want is to generate an expression such as the one below programmatically. There of course is a straight-forward work around, I just don't like dealing with special cases especially when they make no sense.
Expr( If( a, If( b, c) ) )<BR />
*/
expr = Expr( If( a ) );
Insert Into( expr, Expr( If( b, c ) ) );
Show( Name Expr( expr ) );
/*
If( a, b, c)
*/
expr = Expr( not an If( a ) );
Insert Into( expr, Expr( If( b, c ) ) );
Show( Name Expr( expr ) );
/*
not an If( a, If( b, c) )
*/
如果有人有任何见解,或者特别是如果您知道一种可靠地将任何表达式插入到任何其他表达式中的方法(不是通过使用“Eval Insert”或字符串),那就太好了!谢谢!
高级统计建模回复:JMP Expr() 怪异,有人能解释一下吗?有一种解决方法可以完成所请求的任务 - 但实际问题是:为什么?!?尚未得到答复。
添加到Jmp 和 JSL 中的小陷阱
回复:JMP Expr() 怪异,有人能解释一下吗?更多的例子很容易反驳一些假设 - 并添加一些进一步的见解:
expr = Expr( If( a, x ) );
Insert Into( expr, Expr(If( b,c )) );
Show( Name Expr( expr ) ); // if(a,x,b,c)
expr = Expr( If( a ) );
Insert Into( expr, Expr(If( b )) );
Show( Name Expr( expr ) ); // if(a,b)
expr = Expr( List( a ) );
Insert Into( expr, Expr(List( b )) );
Show( Name Expr( expr ) ); // List(a,b)
expr = Expr( Graph Builder( a ) );
Insert Into( expr, Expr(Graph Builder ( b )) );
Show( Name Expr( expr ) ); // Graph Builder(a,b)
expr = Expr( Head( a ) );
Insert Into( expr, Expr(Head( b )) );
Show( Name Expr( expr ) ); // Head(a,b) (!)
expr = Expr( Not( a ) );
Insert Into( expr, Expr(Not( b )) );
Show( Name Expr( expr ) ); // Not(a) (!!)
回复:JMP Expr() 怪异,有人能解释一下吗?你好,
尽管我不确定,但我想知道这种行为是否是因为片段“IF ( a )”不是格式良好的 JSL 表达式。 也就是说,函数 IF 采用 2 个参数,而不是 1 个。 JMP 无法知道“notAnIf( a )”是否是一个格式良好的表达式,因此也许耸耸肩并继续(?)我的全部猜测。
事实上,以下内容按您的意图工作似乎为这个想法添加了一些支持,但这并不能解释为什么@ben_ph的想法是有效的,因为它成功地在我丢失的地方插入了 REPLACE_ME 。
expr = Expr( If( a, . ) );
Substitute Into( expr, expr(.), expr( If( b, c ) ) );
Show( Name Expr( expr ) );

干杯,
布雷迪
回复:JMP Expr() 怪异,有人能解释一下吗?作为不使用字符串的解决方法,您可以执行类似的操作
expr = Expr( If( a ) );
Insert Into( expr, Expr( REPLACE_ME ) );
Substitute Into( expr, Expr( REPLACE_ME ), Expr( If( b, c ) ) );
Name Expr( expr );
// If( a, If( b, c ) )
回复:JMP Expr() 怪异,有人能解释一下吗?这是密切相关与如何将一个列表插入到另一个列表中。 对于你的问题,我现在怀疑内置函数名称有一个特殊的例外,可以显示这种行为。
expr = Expr( not an If( a ) );
是相同的
expr = Expr( NotAnIf( a ) );
将 NotAnIf(或不是 if)设置为函数名称 JMP 不会将其识别为内置函数。 在 { list } 示例中,{...} 与 List(...) 相同,并且是内置函数名称。
expr = Expr( sum( a ) );
插入( expr, Expr( sum( b, c ) ) );
Show( 名称 Expr( expr ) );
/*:
名称 Expr(expr) = Sum(a, b, c);
//:*/
expr = Expr( sum1( a ) );
插入( expr, Expr( sum1( b, c ) ) );
Show( 名称 Expr( expr ) );
/*:
名称 Expr(expr) = sum1(a, sum1(b, c));
我也不喜欢它。
@XanGregg