โ† All Picat Flashcard Decks

General Flashcards

7 cards from real Picat practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 General flashcards as text
  1. Which Picat module should you import to use SAT-based constraint solving instead of CP propagation?

    Answer: sat

    Picat's `sat` module encodes finite-domain constraints as propositional SAT clauses and calls a built-in SAT solver, offering an alternative to the `cp` propagation engine.

  2. What does `bp.pred_name(Args)` syntax allow in Picat?

    Answer: Calling a B-Prolog built-in predicate not natively exposed in Picat

    The `bp.` prefix lets Picat code call B-Prolog predicates directly, since Picat is built on the B-Prolog engine and exposes its built-ins this way.

  3. In Picat, what does the `foreach` loop construct do?

    Answer: Iterates over a list or range, executing a goal for each element without building a return value

    `foreach(E in List, Goal)` executes Goal for each element E in List purely for side effects, analogous to a for-each loop in imperative languages.

  4. What value does `max_list([3,1,4,1,5,9])` return in Picat?

    Answer: 9

    `max_list/1` returns the largest element of the list, which is 9 in this case.

  5. Which Picat feature allows a predicate to be both used for generation and for checking without separate clauses?

    Answer: Unification-based pattern matching with backtracking

    Because Picat predicates use unification and backtracking, the same clause can generate solutions when arguments are unbound and verify correctness when arguments are ground.

  6. What is the correct way to concatenate two strings in Picat?

    Answer: S = S1 ++ S2

    The `++` operator concatenates two strings (or lists) in Picat, returning a new string that is their combination.

  7. When a Picat program uses `cl` (command-line) mode, how is the entry point defined?

    Answer: A predicate named `main` with arity 0 or 1 is called automatically

    When running a Picat script from the command line, the runtime automatically calls the `main/0` or `main/1` predicate (with command-line arguments as a list) as the entry point.