← 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. Which Picat module provides the `sort/1` and `msort/1` predicates for list sorting?

    Answer: lists

    The `lists` module provides `sort/1` (removes duplicates) and `msort/1` (keeps duplicates) for sorting lists.

  2. In the Picat `math` module, what does `gcd(12, 8)` return?

    Answer: 4

    `gcd/2` computes the greatest common divisor, and the GCD of 12 and 8 is 4.

  3. Which function in the Picat `string` module converts a string to uppercase?

    Answer: to_upper/1

    `to_upper/1` from the `string` module returns the uppercase version of a string.

  4. How do you import the `io` module in a Picat program?

    Answer: :- import io.

    Picat uses the `:- import module_name.` directive to import a module.

  5. What does `maps:get(Map, Key, Default)` do when the key is not found in the map?

    Answer: Returns Default

    The three-argument form of `maps:get/3` returns the Default value when the Key is absent from Map.

  6. Which Picat `lists` module predicate checks if an element is a member of a list?

    Answer: member/2

    `member/2` is the standard predicate to test whether an element belongs to a list.

  7. In the Picat `util` module, what does `max_list/1` return?

    Answer: The maximum element in the list

    `max_list/1` traverses the list and returns the largest numerical element.