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
In Picat's constraint module `cp`, which predicate declares an integer decision variable with a domain?
Answer: X :: Lo..Hi
The `::` operator assigns a finite-domain range to a decision variable, e.g., `X :: 1..10` constrains X to integers 1 through 10.
What does `solve([ff], Vars)` do in Picat's constraint solver?
Answer: Searches for values satisfying constraints using the first-fail heuristic
`solve` with option `ff` (first-fail) selects the variable with the smallest remaining domain first, improving search efficiency.
Which Picat built-in computes the length of a list?
Answer: length(List, Len)
`length(List, Len)` unifies Len with the number of elements in List, and can also generate a list of free variables when Len is given.
How does Picat's tabling differ from standard Prolog memoization libraries?
Answer: Tabling is built into the language with the `table` directive and handles cycles automatically
Picat's `table` directive enables SLG-resolution tabling that correctly handles cyclic calls and avoids infinite loops without programmer intervention.
What is the output of `writeln(2 ** 10)` in Picat?
Answer: 1024
The `**` operator in Picat performs integer exponentiation when both operands are integers, so 2**10 evaluates to 1024.
In Picat, which construct allows pattern matching directly in a function/predicate head?
Answer: Multiple clauses with different head patterns
Picat allows multiple clauses for the same predicate/function, each with a distinct head pattern that is tried in order, enabling structural pattern matching.
Which keyword in Picat is used to import a module at the top of a file?
Answer: import
The `import` declaration at the top of a Picat file makes predicates from a named module available in the current file.