Epic Skills Assessment Fictional Programming Language Logic 4 — Questions and Answers
Question 1: In FictoScript, a function declared with `fn*` instead of `fn` is:
- A pointer to another function
- A generator function that can yield multiple values lazily (Correct answer)
- A function with variadic arguments
- A private function that cannot be called externally
Correct answer: A generator function that can yield multiple values lazily
`fn*` defines a generator that uses `yield` to produce values one at a time without computing all results upfront.
Question 2: Which FictoScript keyword is used to handle errors from a function that may fail?
- catch
- rescue (Correct answer)
- guard
- trap
Correct answer: rescue
FictoScript uses `rescue` blocks (not `catch`) to handle errors thrown during execution.
Question 3: In FictoScript, what is the result of applying `map(fn(x) => x * x, [1, 2, 3, 4])`?
- [1, 4, 9, 16] (Correct answer)
- 30 (sum of squares)
- [2, 4, 6, 8]
- [1, 2, 3, 4, 1, 4, 9, 16]
Correct answer: [1, 4, 9, 16]
`map` applies the squaring function to each element, producing a new list of squared values.
Question 4: FictoScript's `record` type differs from a plain `map` type in that a record:
- Is ordered by insertion order while map is unordered
- Has fixed, named fields with defined types, while map allows arbitrary keys (Correct answer)
- Is mutable while map is immutable
- Can only store numeric values
Correct answer: Has fixed, named fields with defined types, while map allows arbitrary keys
A `record` has a fixed schema with typed fields, providing structure guarantees that a `map` does not.
Question 5: What does the FictoScript pipe operator `|>` do?
- Performs a bitwise OR operation
- Passes the result of the left expression as the first argument to the right function (Correct answer)
- Creates a new parallel thread
- Concatenates two strings
Correct answer: Passes the result of the left expression as the first argument to the right function
`|>` chains function calls by passing the left-hand value into the next function, improving readability of transformation pipelines.
Question 6: In FictoScript, a `contract` block attached to a function defines:
- The function's export visibility
- Preconditions and postconditions that are checked at runtime (Correct answer)
- The type signature of the function
- The concurrency model the function uses
Correct answer: Preconditions and postconditions that are checked at runtime
A `contract` block specifies conditions that must hold before (`require`) and after (`ensure`) the function executes.
Question 7: If FictoScript evaluates `true and false or true`, what is the result, assuming standard precedence?
- false
- true (Correct answer)
- A syntax error
- undefined
Correct answer: true
`and` binds tighter than `or`, so this evaluates as `(true and false) or true` = `false or true` = `true`.
In FictoScript, a function declared with `fn*` instead of `fn` is: