1

This is a pseudo-code from "Artificial Intelligence: A modern approach"

function Table-Driven-Agent(percept) returns action
  static: percepts, a sequence, initially empty
          table, a table, indexed by the percept sequences, initially fully specified

  append percept to the end of percepts
  action <-- Lookup(percepts, table)
  return action

In this code and many other codes, there is the keyword static before some declarations. I want to use this keyword in my own algorithm pseudo-code, but I am not sure what is its usage.

  • 5
    Pseudo-code isn't a standardized language, so it means whatever the author wants it to mean. Usually books with lots of psuedocode or special keywords in their pseudocode will have an appendix or something that explains their dialect in detail. – Ixrec Feb 16 '16 at 20:28
  • @Ixrec my psuedo-code has compile errors though :( – enderland Feb 16 '16 at 20:32
  • @Ixrec then you don't suggest me to use it when I'm not sure if it is a common keyword, and when I don't know the intention of this author of using it? – Ahmad Feb 16 '16 at 20:33
  • 3
    @Ahmad if you aren't familiar with the use of static in other languages and the scope of what it may mean (and it means many different things in different languages), then I am not sure you should be using it in pseudocode either. – user40980 Feb 16 '16 at 20:35
  • 1
    @MichaelT: you are not sure? I am very sure he should not use it as long as he does not know what it means ;-) – Doc Brown Feb 16 '16 at 20:39
3

It means persistent (the data persists between calls). The latest version of the pseudo-code has been modified, such that the word "static" was replaced with "persistent". A description of your algorithm from that source: "The TABLE-DRIVEN-AGENT program is invoked for each new percept and returns an action each time. It retains the complete percept sequence in memory."

The word "static" can have very different meanings in different languages, so it was a poor choice.

Here is the updated pseudo-code.

  • Thank you, I guessed so, do you have a reference for pseudo-codes? for example where did you see "persistent" replaced "static'. – Ahmad Feb 17 '16 at 5:28
  • @Ahmad I added a link. – Frank Hileman Feb 17 '16 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.