Exercise : Basic types
For these exercises, the integers are expected to be ≥ 0. Do not consider negative cases.
Write a function e1q1 with type int → string → string such that e1q1 0 "ab""" e1q1 1 "ab""ab" e1q1 2 "ab""abab" e1q1 n ss repeated n times
Write a function e1q4 with type int → int such that e1q4 00 e1q4 11 e1q4 102 e1q4 992 e1q4 9993 e1q4 nthe number of digits of n (except for 0, where it returns 0)
Write a function e1q2 with type int → string → string such that
Note: to get the last digit of a number, usee1q2 0 ":""" e1q2 7 ":""7:" e1q2 72 ":""2:7:" e1q2 987 ":""7:8:9:" e1q2 n sthe (reversed) digits of n, interleaved with s n mod 10.
Remember alsostring_of_int.
Write a function e1q3 similar to e1q2, but the digits are in the right order (not reversed):e1q3 987 "#"returns"9#8#7#"
Write a function e1q5 with type int → bool → bool such that e1q5 0 btrue (whatever b is) e1q5 n truereturns true iff all digits of n are even e1q5 n falsereturns true iff all digits of n are odd e1q5 17359 falsetrue e1q5 17369 falsefalse e1q5 288062 truetrue e1q5 298462 truefalse
Write a function e1q6 with type int → int → bool such that e1q6 n mtrue iff all digits of n are smaller or equal
than the corresponding digits of m (prefixing with zeroes if necessary).e1q6 0 0true e1q6 1234 2345true e1q6 1234 999false (because 999 is actually 0999) e1q6 999 1648false e1q6 333 1444true