Copyright © 2024 SingChun Lee Bucknell University. All rights reserved. Sites developed using revealjs.
Example | Meaning | Explanation |
---|---|---|
x is 3 + 4 | x gets 7 | is does math, then assigns to the left side |
x = 3 + 4 | x gets 3 + 4 | = assigns to both sides |
x == 3 + 4 | false, it wasn't already true | == like Java just sees if things are already equal |
returns | returns | returns | |||
---|---|---|---|---|---|
integer(3) | true | float(3) | true | string(3) | false |
integer(3.14) | false | float(3.14) | true | string(3.14) | false |
integer("hi") | false | float("hi") | false | string("hi") | true |
returns | returns | returns | |||
---|---|---|---|---|---|
not(true) | false | +(3, 4) | 7 | string_concat("a", "b") | "ab" |
not(false) | true | 3 + 4 | 7 | ||
not(integer(3)) | false | +(3.1, 4.2) | 7.3 | ||
not(string(3)) | true | 3.1 + 4.2 | 7.3 |
foo(A, B):- A + B.
foo(3, 4). % ERROR undefined procedure (+)/2
Cannot find a rule named + which takes 2 parameters. It was expecting a normal rule which returns a boolean.
foo(A, B, C):- C _____ A + B % =, ==, or is?
Which operator to make C be the answer of adding two ints?