Answered step by step
Verified Expert Solution
Link Copied!

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. image text in transcribed

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 recursive

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions