Using Standard Modules 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 Using Standard Modules flashcards as text
What is the correct way to open a file for writing in Picat using the `io` module?
Answer: open(File, write, Stream)
`open/3` takes the filename, mode atom (`write`, `read`, or `append`), and binds a stream variable.
Which `sets` module predicate computes the union of two sets represented as sorted lists?
Answer: union/3
`union/3` in the `sets` module takes two sorted lists and produces their union as a sorted list.
In Picat's `math` module, which predicate computes the base-10 logarithm?
Answer: log10/1
`log10/1` computes the base-10 (common) logarithm, while `log/1` computes the natural logarithm.
Which `string` module function splits a string by a delimiter character?
Answer: split/2
`split/2` takes a string and a delimiter string, returning a list of substrings.
What does `:- import lists, sets.` accomplish in a Picat file?
Answer: Imports both the `lists` and `sets` modules
Multiple modules can be imported in a single `:- import` directive by separating them with commas.
In the Picat `maps` module, which predicate creates a new empty map?
Answer: new_map/1
`new_map/1` binds a variable to a fresh, empty map data structure in Picat.
Which `util` module function returns the minimum value in a list?
Answer: min_list/1
`min_list/1` returns the smallest element of a numerical list, symmetric to `max_list/1`.