Skip to content

Comment on Rethinking Prologparent

Comments

arithmetic is evaluated by 'is'

  ?- A is 10-2, write(A).
  8
  A = 8.
  %or
  ?- use_module(library(clpfd)).
  true.
  ?- A #= 10-2, write(A).
  8
  A = 8.
  %this lets you do the other thing too
  ?- 8 #= A-2, write(A).
  10
  A = 10.
foreach doesn't really work the way you want it though, in this case you want forall.
  ?- forall(between(0,5,N), (A is 5-N,writeln(A))).
  5
  4
  3
  2
  1
  0
  true.

Wow... ok... I can calm down a bit... thanks for the help!

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.