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