Switch statements in Prolog

前端 未结 3 1394
死守一世寂寞
死守一世寂寞 2021-01-17 17:51

In Prolog predicates, I often write repetitive conditional statements like this one, but I wish they could be written more concisely:

output(Lang, Type, Outp         


        
3条回答
  •  旧巷少年郎
    2021-01-17 18:32

    It seems that multiple clauses are made for this use case and also quite concise.

    output(javascript, Type, ["javascript", Type]).
    output(ruby, Type, ["def", Type]).
    output(java, Type, [Type]).
    

提交回复
热议问题