Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1a
- let printList list =
- let rec helper index list =
- match list with
- | [] -> ()
- | head :: tail ->
- printfn "%d.) %A" index head
- helper (index + 1) tail
- helper 1 list
- printList a
- //1 c
- let max2 x y = if x > y then x else y;;
- let rec getMax xs =
- match xs with
- | [] -> 0
- | [x] -> x
- | x1::x2::xs' -> getMax((max2 x1 x2)::xs')
- printfn "%i" ( getMax [9;2;5;23;11;17;6])
- //3 a
- let isNthChar(str:string, n:int, c:char):bool =
- if str.[n] = c then true
- else false
- printfn "%b" (isNthChar("rohit", 2, 'h'))
- // 3b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement