โ† All Picat Flashcard Decks

Data Structures and Types 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 Data Structures and Types flashcards as text
  1. How do you create a new empty map in Picat?

    Answer: new_map()

    Picat provides the built-in `new_map()` function to create an empty hash map.

  2. What is the correct syntax to access element at index 2 of array A in Picat?

    Answer: A[2]

    Picat arrays use bracket notation `A[I]` for indexed access, with indexing starting at 1.

  3. Starting from which index do Picat arrays begin?

    Answer: 1

    Picat arrays are 1-indexed by default, so the first element is at index 1.

  4. What does `to_array([a, b, c])` return in Picat?

    Answer: {a, b, c}

    `to_array/1` converts a list to a Picat array represented with curly-brace notation `{a, b, c}`.

  5. Which function retrieves a value from Picat map M using key K?

    Answer: get(M, K)

    `get(M, K)` is the built-in to retrieve the value associated with key K from map M.

  6. How do you insert key K with value V into Picat map M?

    Answer: put(M, K, V)

    `put(M, K, V)` inserts or updates the key-value pair in the map, which is a mutable operation in Picat.

  7. What does `array({1, 2, 3})` evaluate to in Picat?

    Answer: true

    The `array/1` predicate succeeds (returns true) when its argument is a Picat array denoted with curly braces.