6.9.8 Checking for a cycle: is_cycle
The is_cycle command is a boolean function which checks to
see if a list represents a cycle.
-
is_cycle takes one argument:
L, a list.
- is_cycle(L) returns 1 if L is a cycle and
returns 0 if L is not a cycle.
Examples.
-
Input:
is_cycle([2,1,3])
Output:
- Input:
is_cycle([2,1,3,2])
Output: