Epic Skills Assessment Fictional Programming Language Logic 3 — Questions and Answers
Question 1: In FictoScript, what is the output of `let y := 5; y := y * 2; print(y)`?
- 5
- 10 (Correct answer)
- A compile error because let variables cannot be reassigned
- undefined
Correct answer: 10
`let` in FictoScript declares a mutable variable, so reassignment is allowed, and y becomes 10.
Question 2: A FictoScript `match` expression that has no matching case and no `default` branch will:
- Return 0
- Throw a MatchError at runtime (Correct answer)
- Skip silently and return none
- Repeat the match expression
Correct answer: Throw a MatchError at runtime
Without a `default` branch, a FictoScript `match` that finds no matching case raises a MatchError.
Question 3: In FictoScript, what does the `@pure` annotation before a function declaration guarantee?
- The function executes faster than unannotated functions
- The function has no side effects and always returns the same output for the same input (Correct answer)
- The function is private and cannot be exported
- The function only accepts primitive types as arguments
Correct answer: The function has no side effects and always returns the same output for the same input
`@pure` marks a function as referentially transparent — no side effects and deterministic output.
Question 4: Which FictoScript scope rule applies to variables declared inside a `loop` block?
- They are accessible throughout the entire function
- They are globally accessible
- They are scoped only to the loop block and are destroyed after each iteration
- They persist across iterations but are destroyed when the loop ends (Correct answer)
Correct answer: They persist across iterations but are destroyed when the loop ends
Loop-block variables in FictoScript persist across iterations but go out of scope when the loop terminates.
Question 5: In FictoScript, the `fold` function applied to a list processes it by:
- Reversing the list elements
- Filtering out elements that fail a predicate
- Accumulating a single value by applying a binary function from left to right (Correct answer)
- Duplicating each element in the list
Correct answer: Accumulating a single value by applying a binary function from left to right
`fold` reduces a list to a single accumulated result using a binary function applied sequentially.
Question 6: FictoScript's `unless` keyword is best described as:
- A post-condition assertion
- An inverted conditional that executes when the condition is false (Correct answer)
- A loop that runs until a condition becomes true
- A try-catch alternative
Correct answer: An inverted conditional that executes when the condition is false
`unless condition` executes its block only when the condition evaluates to false, opposite of `when`.
Question 7: What happens in FictoScript when you access index 5 of a list that only has 3 elements?
- Returns 0 by default
- Returns none
- Throws an IndexOutOfRange error (Correct answer)
- Wraps around and returns the element at index 2
Correct answer: Throws an IndexOutOfRange error
FictoScript raises an IndexOutOfRange error when accessing an index beyond the list's bounds.
In FictoScript, what is the output of `let y := 5; y := y * 2; print(y)`?