Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在编写一个程序来执行以下操作。如果我有一个 [0,1]* 列表并且我的示例列表是 [0,1,0,0,1],我想编写一个返回为我计数。如果数字为 0 ,则计数增加,当数字为 1 时,计数减少。
dd(0)-->[]. dd(Newcnt)-->[0],dd(Cnt),{Newcnt is Cnt + 1}. dd(Newcnt)-->[1],dd(Cnt),{Newcnt is Cnt - 1}.