AboutGDPROthersSitemap

Predicates in no-web

“?” or “is”

Programmers who use one or more of then Lisp-dialects are familiair with the term predicate. In computer science predicates are directly derived from Mathematial Logic.

In Literate Programming, one tries to write and show the structure of an algorithm without having to mind about technicalities and house keeping. One way to do that is to wrap some if's into predicates using some natural language construct. Some Lisp's do this by adding a “?” at the end of a name. So in clojure we may have:

(odd? 3)

t

odd? is a predicate for numbers and is true for all odd numbers.

No-web, the macro-feature of org-mode, doesn't support matching macro-names ending in “?”. So I had to come up with a different approach.

While explaining predicate logic, often the word (prefix if you want) is is used. So the name of the predicate odd? can also be: is odd.

Throughout the code in this site, I try to maintain the use of is for predicates.

Sometimes predicates are simple flags needing assignments sometimes (try to avoid that guys, there's nothing like immutability). The word to use for trueing or falsing something is hard to find. I've found no literature with a satisfying answer.

I will use enable for now. So the following code prints "OK":

<<enable in body>>
if <<is in body>> {
  fmt.printf( "Ok" )
}

Please let me know if this is a bad idea.

about this title

The document to generate the scripts has the same source as the document you are reading now.

Most scripts are bare bone, the amount of fancy stuff is kept to an absolute minimum in order to present only the concepts at hand and only that.

This title was written on the 21st September 2017