subject

1. In this lab, you will use 5 different programming languages to solve the same problem: Write and use a generic sort function. This function should be able to sort values of any type that has some notion of order. The values to sort could be integers, floating point numbers, strings, pairs of values (say a string and a number), etc. 2. Write a console application in each of these 5 languages: C, C++, C#, Python and Haskell.
3. Each application has to use the following data:
The sequence of floating point numbers: 645.32, 37.40, 76.30, 5.40, -34.23, 1.11, -34.94, 23.37, 635.46, -876.22, 467.73, 62.26
The following sequence of people with name and age of each person. The name is a string and the age an integer: Hal, 20; Susann, 31; Dwight 19; Kassandra, 21; Lawrence, 25; Cindy, 22; Cory, 27; Mac, 19; Romana, 27; Doretha, 32; Danna, 20; Zara, 23; Rosalyn, 26; Risa, 24; Benny, 28; Juan, 33; Natalie, 25
Use appropriate data structures to represent the data above in each of the 5 languages and define the variables numbers and people, respectively.
4. Write one generic sort function in each of the 5 languages. Hints:
(i) The objective of this assignment is to understand generics (not sorting). You can use the sort functions from Lab Assignment 1 or just use a sort function provided in some standard library for the respective language.
(ii) C doesn’t provide any generics. However, a void*can be used to point to any value.
(iii) One way to specify an order on a type is to define a comparison function that compares two values. This comparison function could be an argument to your sort function. Some languages might provide predefined comparison functions.
(iv) Try to use everything we learned about these different programing languages, e. g., Python uses duck-typing, Haskell uses the type-class Ord to express order on a type, LINQ in C# includes the orderby operator, etc.
5. Use your generic sort function to
(i) sort numbers ascending by numerical value,
(ii) sort people alphabetically (lexicographically) by name, and to
(iii) sort people descending by age, where people of the same age should be sorted alphabetically (lexicographically).
6. The point here is to use the same function to do all 3 different sort operations. Try to reuse as much of your code and focus on clarity and brevity.
7. Write a main function in each of the 5 languages that will print out the results to the console.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:00
What machine listens for http requests to come in to a website’s domain? a. a router b. a browser c. a server d. a uniform resource locator
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Light travels at a speed of 186,000 miles a second. the distance light travels in a year is 5,865,690,000,000 miles/year 5,865,695,000,000 miles/year 58,656,950,000,000 miles/year 6,789,000,0000 miles/year
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
What is one reason why indoor air pollution has become an increasing problem.
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
The gene form of a trait is called a(n) 
Answers: 2
You know the right answer?
1. In this lab, you will use 5 different programming languages to solve the same problem: Write and...
Questions
question
Mathematics, 14.12.2020 19:00
question
Mathematics, 14.12.2020 19:00
question
Mathematics, 14.12.2020 19:00
question
Mathematics, 14.12.2020 19:00
Questions on the website: 13722362