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
In Picat, what type does the literal `"hello"` (double-quoted) have?
Answer: String — its own distinct type
In Picat, double-quoted literals are of the `string` type, which is distinct from atoms and lists.
Which predicate tests if X is a Picat string (double-quoted value)?
Answer: string(X)
`string(X)` succeeds when X is a Picat string literal (double-quoted), distinguishing it from atoms.
How do you convert integer N to its atom representation in Picat?
Answer: to_atom(N)
`to_atom(N)` converts any Picat term including integers to its atom representation.
What does `string_codes("ab", Cs)` bind Cs to in Picat?
Answer: [97, 98]
`string_codes/2` converts a string to a list of Unicode code points; 97 = 'a' and 98 = 'b'.
What does `atom_length(hello, N)` bind N to in Picat?
Answer: 5
`atom_length/2` counts the characters in the atom's name; 'hello' has 5 characters.
Which predicate checks if X is an atom (not a string or number) in Picat?
Answer: atom(X)
`atom(X)` is the standard Picat predicate that succeeds when X is an unquoted atom like `hello` or `foo`.
How do you convert the string "42" to the integer 42 in Picat?
Answer: to_integer("42")
`to_integer/1` is Picat's built-in for converting strings and other terms to integer values.