if elseif在Netlogo环境中的实现

Abh*_*tia 5 netlogo

我希望 - if elseif else在NetLogo中发表声明.我怎么能有效地这样做?我检查了NetLogo文档没有命令这样做.以前的类似问题 没有直接回答,而是在上下文中解决.

一个简单的解决方案是

    let flag true
    if(condition1)
    [
    ...
    set flag false
    ]
    if(flag and condition2)   ;else if statement
    [
    ...
    set flag false
    ]
    if(flag)  ;else statement
    [

    ...
    ]
Run Code Online (Sandbox Code Playgroud)

我正在寻找其他更高效的.

编辑: 根据Nicolas的建议在第二个if条件中添加标记.

Set*_*sue 4

我可以全心全意推荐的唯一方法是:

ifelse condition1
  [ ... ]
  [ ifelse condition2
      [ ... ]
      [ ifelse condition3
        [ ... ]
        [ ifelse ...
Run Code Online (Sandbox Code Playgroud)

但是,是的,缩进和可读性不是很好。有关可能的最终改进的想法,请参阅https://github.com/NetLogo/NetLogo/issues/344https://github.com/qiemem/ControlFlowExtension