Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use F# language. Can someone help me with these two exercise. Exercise 2.3 Write a function combinePair int list-(int int) list so that combinePair
Please use F# language. Can someone help me with these two exercise.
Exercise 2.3 Write a function combinePair int list-(int int) list so that combinePair xs returns the list with elements from xs combined into pairs. If xs contains an odd number of elements, then the last element is thrown away: combinePair [xl x2; x3; x4] -(x1, x2); (x3, x4)1 combinePair [x1; x2; x3] = [(x1,x2)] combinePair [] = [] combinePair [x1] = [] Hint: Try use pattern matching. Exercise 2.4 Write a function explode string ->char list so that explode s returns the list of characters in s explode "star" = [ , s' ; , t, ; , a, ; , r' ] Hint: if s is a string then s.ToCharArray ( returns an array of characters. You can then use List.ofArray Now write a function explode2 string -> char list to turn it into a list of characters. similar to explode except that you now have to use the string function s . chars (orLD, where s is a string. You can also make use of s.Remove (0,1).The definition of explode2 will be recursive. Exercise 2.3 Write a function combinePair int list-(int int) list so that combinePair xs returns the list with elements from xs combined into pairs. If xs contains an odd number of elements, then the last element is thrown away: combinePair [xl x2; x3; x4] -(x1, x2); (x3, x4)1 combinePair [x1; x2; x3] = [(x1,x2)] combinePair [] = [] combinePair [x1] = [] Hint: Try use pattern matching. Exercise 2.4 Write a function explode string ->char list so that explode s returns the list of characters in s explode "star" = [ , s' ; , t, ; , a, ; , r' ] Hint: if s is a string then s.ToCharArray ( returns an array of characters. You can then use List.ofArray Now write a function explode2 string -> char list to turn it into a list of characters. similar to explode except that you now have to use the string function s . chars (orLD, where s is a string. You can also make use of s.Remove (0,1).The definition of explode2 will be recursiveStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started