Question

New to Ocaml, suppose to implement a function which takes two tuples (a,b) (c,d) and determine...

New to Ocaml,
suppose to implement a function which takes two tuples (a,b) (c,d) and determine if a/b equal to c/d. abcd are all int. Stuck on the point that a/b , c/d are different type...
Can someone help me implement this small piece of code in Ocaml?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Convert all a, b, c and d into double and then run the check.

Or try to determine their data types before and throw error if all can not be converted to same data types.

Add a comment
Know the answer?
Add Answer to:
New to Ocaml, suppose to implement a function which takes two tuples (a,b) (c,d) and determine...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose: Relation S(B,C,D) has the following tuples: 68 79 Which of the following tuples is NOT...

    Suppose: Relation S(B,C,D) has the following tuples: 68 79 Which of the following tuples is NOT in the result of the following query: SELECT Sum( BC) ASSUM, Max(D) AS MAX FROM S GROUP BY B; O (2,8,6) O (4,52,9) O (4,24,8) None of the above

  • in c++ You must implement the function: string get_ap_terms(int a, int d, size_t n); which returns...

    in c++ You must implement the function: string get_ap_terms(int a, int d, size_t n); which returns a string containing the first n terms of the arithmetic progression (AP) as a sequence of comma-separated values. Recall that an AP is specified by two terms a and d. The first term is a, and the d is how much you add to each term to get the next term. So the first N terms of the above AP will be: a, a+d,...

  • PROGRAMMING PROJECTS Implement the class umapHash Key, which creates a hash function for miniPair...

    Data Structure in C++ please type the code and the output. thanks PROGRAMMING PROJECTS Implement the class umapHash Key, which creates a hash function for miniPair ob- iects that uses only the key of the pair (first). The third template argument is a func- tion object type that takes a Key argument. Place the class in the header file "umaphash.h" 37. (a) // a hash function object type that applies KeyHashFunc // to the key in a miniPair object template...

  • in c++ please explain with answer 6. Given the following template function definition, which of the...

    in c++ please explain with answer 6. Given the following template function definition, which of the following is not a valid invocation of the function? template <class T> a. swap(s1,s2); void swap(T& left, T& right) b. swap(int1, int2); { c. swap(ch1, ch2); //implementation d. swap(int1, ch2); } int int1, int2; float flt1, flt2; char ch1, ch2; string s1, s2; 7. Why can you not use the swap template function to swap two complete arrays? template <class T> void swap(T& left,...

  • In C++ 9) (5 pts) Complete the following function that takes 3 arguments of a circle...

    In C++ 9) (5 pts) Complete the following function that takes 3 arguments of a circle : - radius (input argument) - area (output argument, to be calculated) - circumference (output argument, to be calculated) All arguments are double type. If a radius is negative, the function returns false, otherwise it returns true. The function does only calculation, and does nothing else. Assume that all #include are already there                                     // Fill in your Function prototype bool circleAreaAndCircumference ( _______,...

  • Question 1 Which pre-written C function can be used to determine if two strings are the...

    Question 1 Which pre-written C function can be used to determine if two strings are the same? A) equals B) strcmp C) strlen D) strcpy E) None of the Above Question 2 The function below is most like which existing string function? int f(char a[ ]) {                int count = 0;                while (a[count] != ‘\0’)                               count++;                return count; } A) strcat B) strcmp C) strcpy D) strlen E) None of the Above Question 3 The function...

  • c++ 1) Write a header file that contains the prototype for a function that takes two...

    c++ 1) Write a header file that contains the prototype for a function that takes two value parameters (both floats) and returns a single character output. The function name is “charIn”. We do not care what the function does at this point. (8) 2)   Fix the Errors of the C++ program: a.   #include <cmath> b.   Void main(){cout<< “Math test”<<endl;//start math test c.   Int i=10 int j=3 k=i%3 cout << “test of mod<<k<<endl d.   Float d=0 float f=e/d cout << “div...

  • For C++ This is the information about the meal class 2-1. (24 marks) Define and implement...

    For C++ This is the information about the meal class 2-1. (24 marks) Define and implement a class named Dessert, which represents a special kind of Meal. It is to be defined by inheriting from the Meal class. The Dessert class has the following constructor: Dessert (string n, int co) // creates a meal with name n, whose type // is "dessert" and cost is co The class must have a private static attribute static int nextID ; which is...

  • Which of the four are true? a). Generic code only works with values of reference types....

    Which of the four are true? a). Generic code only works with values of reference types. b). Autoboxing is when a reference type is automatically converted into the corresponding primitive type. c). Java will always add a default constructor to any class that you define. d). All exceptions in Java implement the Throwable interface. e). Generic algorithms allow you to write code that can operate on arguments of multiple different types f). The type wrapper for the int primitive type...

  • Programming Problem: define a C++ Bucket class with the following methods: Bucket() constructor that takes two...

    Programming Problem: define a C++ Bucket class with the following methods: Bucket() constructor that takes two parameters, a string name and an int parameter, the bucket capacity print) takes no paramers. Prints the bucket name, capacity and contents. Returns void. fill) that takes no parameters, fills the bucket to capacity. Returns void. empty ) that takes no parameters, empties the bucket. Returns void pourinto) takes one parameter, a reference to a Bucket object, returns an int that is the number...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT