Previous Up Next

2.10.7  Checking for a cycle : is_cycle

is_cycle is a boolean function.
is_cycle takes a list as argument.
is_cycle returns 1 if the argument is a cycle and returns 0 if the argument is not a cycle.
Input :

is_cycle([2,1,3])

Output :

1

Input :

is_cycle([2,1,3,2])

Output :

0

Previous Up Next