Epic Skills Assessment Fictional Programming Language Logic 5 — Questions and Answers
Question 1: In FictoScript, the `freeze` function applied to a list will:
- Sort the list in ascending order
- Make the list immutable so no elements can be added, removed, or changed (Correct answer)
- Convert all elements to their string representations
- Pause execution until the list operation completes
Correct answer: Make the list immutable so no elements can be added, removed, or changed
`freeze` locks a data structure, making any subsequent mutation attempts raise a FrozenError.
Question 2: Which FictoScript feature allows a single function name to behave differently based on argument types?
- Overloading via `fn/type` dispatch (Correct answer)
- Macros
- Mixins
- Prototype chaining
Correct answer: Overloading via `fn/type` dispatch
FictoScript supports type-based dispatch by defining multiple `fn/type` signatures under the same function name.
Question 3: A FictoScript `lazy val` is evaluated:
- At the time it is declared
- Every time it is accessed
- Only the first time it is accessed, then cached (Correct answer)
- Only inside loop blocks
Correct answer: Only the first time it is accessed, then cached
`lazy val` defers computation until first use, then memoizes the result so subsequent accesses are instant.
Question 4: In FictoScript, what does `filter(fn(x) => x mod 2 == 0, [1, 2, 3, 4, 5, 6])` return?
- [1, 3, 5]
- [2, 4, 6] (Correct answer)
- [0, 0, 0]
- [1, 2, 3, 4, 5, 6]
Correct answer: [2, 4, 6]
`filter` keeps only elements where the predicate returns true; here, even numbers pass the `mod 2 == 0` check.
Question 5: FictoScript's `trait` keyword is most similar to which concept in other languages?
- A concrete class with full implementations
- An interface or mixin that defines behavior a type must implement (Correct answer)
- A global constant namespace
- A type alias
Correct answer: An interface or mixin that defines behavior a type must implement
A `trait` defines a set of method signatures (and optionally default implementations) that types can adopt.
Question 6: What is the purpose of FictoScript's `seal` keyword applied to a module?
- Encrypts the module's source code
- Prevents external modules from extending or overriding the module's definitions (Correct answer)
- Compresses the module for faster loading
- Marks all module functions as `@pure`
Correct answer: Prevents external modules from extending or overriding the module's definitions
A `seal`ed module cannot have its definitions monkey-patched or extended by other modules, ensuring stability.
Question 7: In FictoScript, if a `loop` body contains `break(42)`, what happens?
- The program terminates with exit code 42
- The loop exits and the entire loop expression evaluates to 42 (Correct answer)
- 42 is appended to the loop's result list
- A BreakError with value 42 is thrown
Correct answer: The loop exits and the entire loop expression evaluates to 42
FictoScript loops are expressions; `break(value)` exits the loop and returns that value as the loop's result.
In FictoScript, the `freeze` function applied to a list will: