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