← All Picat Flashcard Decks

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
  1. What does `maps:put(Map, Key, Value, NewMap)` do?

    Answer: Creates NewMap as Map with Key→Value added or updated

    `maps:put/4` is a functional-style operation producing NewMap from Map with the Key→Value binding added or overwritten.

  2. In the Picat `lists` module, what does `flatten/2` do?

    Answer: Converts a nested list into a flat list

    `flatten/2` recursively removes nesting from a list, producing a flat single-level list.

  3. Which predicate in Picat's `io` module reads a single character from standard input?

    Answer: get_char/1

    `get_char/1` reads the next character from the current input stream and unifies it with its argument.

  4. What is the result of `sets:intersection([1,2,3,4], [2,4,6])` in Picat?

    Answer: [2,4]

    Set intersection returns only elements present in both lists, which are 2 and 4.

  5. Which `math` module function raises a number to a power in Picat?

    Answer: pow/2

    `pow/2` computes X to the power Y; the `**` infix operator also works for the same purpose.

  6. In Picat's `string` module, what does `string_to_atom/2` do?

    Answer: Converts a string to an atom

    `string_to_atom/2` takes a string as first argument and unifies the second argument with the corresponding atom.

  7. What module must be imported to use Picat's constraint programming (`#=/2`, `#</2`) operators?

    Answer: cp

    Picat's `cp` module provides finite-domain constraint operators like `#=`, `#` along with `solve/1`.