if
, write a function
isDivBy3: num -> bool;which returns true if and only if its argument is divisible by 3.
if
, write a function
isDivBy: num # num -> bool;which returns true if and only if its first argument is divisible by its second argument.
isDivBy3
using
isDivBy
.
contains
contains: alpha # list(alpha) -> bool;
contains(x,k)
returns true if and only if list k
contains x
.
isPalindrome: list alpha -> bool;which returns true if and only if its argument is a palindrome. e.g.
isPalindrome [1,2,1]
is true but
isPalindrome [1,2]
is false.
remove
,
remove: alpha # list alpha -> list(alpha);Such that
remove(x,k)
removes all occurrences of x
from the list k
.
For example remove(2,[3,2,3,2,3,4])
gives [3,3,3,4]
.
removeDuplicates
,
removeDuplicates: list (alpha) -> list(alpha);Such that
removeDuplicates k
removes all duplicates from k.
For example removeDuplicates([3,2,3,2,3,4])
gives [3,2,4]
.
isPermutation: list alpha # list alpha -> bool;
isPermutation(k,m)
returns true if and only if k
and m
are permutation of each other.
For example [1,2,3,1]
and [1,3,1,2]
are permutations but
[1,2,3,1]
and [1,3,2]
are not.
s.danicic@gold.ac.uk