Picat Cheat Sheet 2026
The 30 highest-yield Picat facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
145 questions
165 min time limit
31% to pass
- What does `spy(Predicate)` do in Picat? → Sets a breakpoint on a specific predicate
- Silicon chips are mostly utilized in → integrated circuits
- What predicate writes a term followed by a newline to standard output in Picat? → writeln(T)
- Friendly most of the time → Friendly
- Which predicate reads a full line from standard input in Picat? → read_line(L)
- What does the second argument in `error(ErrorTerm, Context)` provide in Picat? → Context information about where the error occurred
- A Picat script needs to be executed from the command line with several arguments. How can the script access these arguments? → By calling `sys:get_args()`
- How do you generate the 7-times multiplication table (7×1 through 7×10) as a list using a Picat list comprehension? → [7*X : X in 1..10]
- Which operator concatenates two strings or lists in Picat? → S1 ++ S2
- To execute an external command-line program (e.g., `ls -l` or `dir`) from within a Picat script and capture its output, which predicate is most suitable? → os:shell(Command, Output)
- How does Picat handle a call to a function for which no pattern-matching rule applies? → The call raises an exception and terminates the program.
- What is the correct Picat syntax for a list comprehension that collects all elements X from list L where X > 0? → [X : X in L, X > 0]
- How many elements does [X : X in 1..5, Y in 1..5, X =:= Y] produce in Picat? → 5 (one element for each pair where X equals Y)
- Of the following, which one is NOT a fruit? → Carrots
- Which of the following imperative constructs in Picat is used to mark the end of a block for loops (`while`, `foreach`) and conditionals (`if-then-else`)? → end
- Ascorbic acid is referred to as → Vitamin A
- How do you close a file stream after I/O operations in Picat? → close(Stream)
- Which of the following Picat code snippets will result in an instantiation error? → main => while (N > 0) N := N - 1 end, println(N).
- What is the core mechanism within Picat's planner module that prevents infinite loops when searching a state space that contains cycles? → The automatic tabling of every state encountered during the search.
- Any celestial body revolving around a massive body is referred to as → A satellite
- How do you re-throw a caught exception from inside a handler in Picat? → throw(Error)
- A developer needs to read the entire content of a text file named `config.txt` into a single string. Which function from the `io` module should be used? → io:read_file_to_string("config.txt")
- How can you write a catch clause that matches any exception regardless of type in Picat? → catch(Goal, _, Handler)
- What an anemometer measures → Wind Speed
- Which of the following demonstrates using a Picat list comprehension with a built-in aggregate operation? → sum([X : X in 1..100, X mod 2 =:= 0]) computes the sum of all even numbers from 1 to 100
- A vector can be used to represent force. A vector is indicative of → Magnitude and Direction
- What happens if no `catch` clause matches a thrown exception in Picat? → The exception propagates up the call stack
- Parity almost exactly entails → Equality
- How does Picat handle multiple generators in [X+Y : X in [1,2], Y in [10,20]]? → It computes the Cartesian product, yielding [11, 21, 12, 22]
- What does `split(Str, Sep)` return in Picat? → A list of substrings split by Sep
Turn these facts into recall: