Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Urgent help, will give thumbs up and good feedback, thank you! Write the following functions on list operations both provided by the standard library and
Urgent help, will give thumbs up and good feedback, thank you!
Write the following functions on list operations both provided by the standard library and useful utility functions.
Language to be used - F#
Exercise #04: find Litem The function find returns the index of the first occurrence of item in the list L, or raise an exception if no such item is found. Write it in the Project02-04.fs file. // // find L item // // Finds the first occurance of item in L and returns the index, // or raise a System.ArgumentException if there isn't any. // // Examples: find [] 0 => raises an exception // find [94] 2 => raises an exception // find [94] 94 => 0 find [3; 45; 6; 3] 3 => 0 // find ['q'; 'w'; 'e'; 'r'; 't'; 'y'] 'y' => 5 // You may not call List.find, List.pick, List.tryFind, List.nth, .[], etc directly in your solution, but you can call the nth function you implemented in exercise#03. // Exercise #05: count Litem The function count returns the number of occurrence of item in the list L. Write it in the Project02-05.fs file. // // count L item // // Returns the number of times item appears in L // // Examples: count ['f'; i'; 'n'; 'a'; 'l'; // a'; 'n'; 't'; 'a'; 's'; 'y'] 'f')) => 2 // count [] 5 => 0 // count [3; 45; 6; 3] 3 => 2 // You may not call List.find, List.pick, List. tryFind, List.nth, .[], etc directly in your solution, but you can call the nth function you implemented in exercise#03. // 'f'; 1 Exercise #13: GCD int1 int2 The function GCD calculates the greatest common divisor of two positive integers int1 and int2. You can use the Euclidean algorithm, or you can do brute force testing, as long as the runtime is linear in terms of the smaller integer in the input. You may find integer division (/) and the integer modulo operator (%) useful in solving this problem. The GCD function should be written in the Project02-13.fs file. // // GCD inti int2 // // Returns the greatest common divisor of int1 and int2 // // Examples: // GCD 5 10 => 5 GCD 54 24 => 6 // GCD 341341341 341341 => 341 // //Step 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