Prolog - unusual cons syntax for lists

后端 未结 3 1402
囚心锁ツ
囚心锁ツ 2020-12-11 14:29

I have come across an unfamiliar bit of Prolog syntax in Lee Naish\'s paper Higher-order logic programming in Prolog. Here is the first code sample from the paper:<

3条回答
  •  悲&欢浪女
    2020-12-11 15:04

    This syntax comes from NU-Prolog. See here. It's probably just the normal list functor '.'/2 redefined as an infix operator, without the need for a trailing empty list:

    ?- L= .(a,.(b,[])).
    L = [a,b]
    Yes (0.00s cpu)
    ?- op(500, xfy, '.').
    Yes (0.00s cpu)
    ?- L = a.b.[].
    L = [a,b]
    Yes (0.00s cpu)
    

提交回复
热议问题