Epic Skills Assessment Fictional Programming Language Logic 2 — Questions and Answers
Question 1: In FictoScript, the statement `bind x := 42` followed by `bind x := 99` results in which outcome?
- x holds 99 because the second bind overwrites the first
- A compile error because bind is immutable once assigned (Correct answer)
- x holds 42 because the first bind takes precedence
- Both values are stored and x returns a list [42, 99]
Correct answer: A compile error because bind is immutable once assigned
In FictoScript, `bind` declares an immutable variable; reassigning it is a compile-time error.
Question 2: Which FictoScript operator returns the remainder after division?
- //
- %%
- mod (Correct answer)
- rem
Correct answer: mod
FictoScript uses the keyword `mod` as the modulo operator, not a symbol.
Question 3: A FictoScript `when` block that lacks an `else` clause and whose condition is false will:
- Throw a runtime exception
- Execute the first branch anyway
- Do nothing and continue execution after the block (Correct answer)
- Terminate the program
Correct answer: Do nothing and continue execution after the block
A `when` block with no `else` is a no-op when the condition is false; execution resumes after the block.
Question 4: In FictoScript, the `spawn` keyword is used to:
- Declare a new variable in the current scope
- Create a new function definition
- Launch a concurrent execution thread (Correct answer)
- Import an external module
Correct answer: Launch a concurrent execution thread
`spawn` initiates a lightweight concurrent task that runs alongside the main execution flow.
Question 5: What does the FictoScript expression `[1, 2, 3] ++ [4, 5]` evaluate to?
- [1, 2, 3, 4, 5] (Correct answer)
- [[1, 2, 3], [4, 5]]
- 8 (sum of all elements)
- A type error
Correct answer: [1, 2, 3, 4, 5]
The `++` operator in FictoScript concatenates two lists into a single flat list.
Question 6: In FictoScript, a `maybe` type is designed to handle:
- Random or probabilistic values
- Values that may or may not be present (nullable values) (Correct answer)
- Asynchronous future values
- Values that alternate between two states
Correct answer: Values that may or may not be present (nullable values)
A `maybe` type represents an optional value that is either `some(value)` or `none`, preventing null reference errors.
Question 7: Which FictoScript construct allows a function to call itself?
- loop self
- recur (Correct answer)
- self-invoke()
- repeat fn
Correct answer: recur
FictoScript uses the `recur` keyword to explicitly perform a recursive call within a function.
In FictoScript, the statement `bind x := 42` followed by `bind x := 99` results in which outcome?