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

  • 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...

  • 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...

  • 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...

  • 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...

  • Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D....

    Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D. Decryption Implement two decryption functions corresponding to the above ciphers. When decrypting ciphertext, ensure that the produced decrypted string is equal to the original plaintext: decryptCaesar(ciphertext, rshift) == plaintext decryptVigenere(ciphertext, keyword) == plaintext Write a program decryption.cpp that uses the above functions to demonstrate encryption and decryption for both ciphers. It should first ask the user to input plaintext, then ask for a right...

  • Just Q3 and Q4 Q1] Write a C function to implement the binary search algorithm over...

    Just Q3 and Q4 Q1] Write a C function to implement the binary search algorithm over an array of integer numbers and size n. The function should return the index of the search key if the search key exists and return - 1 if the search key doesn't exist. [10 Points] Q2] Write a C function to implement the selection sort algorithm, to sort an array of float values and size n. The function should sort the array in ascending...

  • Write Java code to implement a FSM machine that recognizes the language for the alphabet {a,b,c} ...

    Write Java code to implement a FSM machine that recognizes the language for the alphabet {a,b,c} consisting of all strings that contain two consecutive c's and end with b.                   Your FSM program should include the following three static methods (Java) or functions (C):                                           a.    int nextState(int state, char symbol)                                  A state-transition function that returns the next state based on the                                  current state and an input symbol. This function should also return                                  -1 when an invalid input character is detected.                                  State...

  • D and e only. Can someone help with this. C++ only. Show work if possible. Thanks...

    D and e only. Can someone help with this. C++ only. Show work if possible. Thanks Name: 3, (30%) Consider the following class definition: class SomeClass public: SomeClass (): SomeClass (); void set1 (int val); void set2 (int val); void add (SomeClass m); int getl ) int get2 0 private: static int numobjs; int meml; int mem2 SomeClass x1, x2; (a) Draw a box around every mutator function in this class. (b) Circle every accessor function in this class. (c)...

  • In C++ Fix any errors you had with HW5(Fraction class). Implement a function(s) to help with...

    In C++ Fix any errors you had with HW5(Fraction class). Implement a function(s) to help with Fraction addition. \**************Homework 5 code*****************************/ #include<iostream> using namespace std; class Fraction { private: int wholeNumber, numerator, denominator;    public: //get methods int getWholeNumber() { return wholeNumber; } int getNumerator() { return numerator; } int getDenominator() { return denominator; } Fraction()// default constructor { int w,n,d; cout<<"\nEnter whole number : "; cin>>w; cout<<"\nEnter numerator : "; cin>>n; cout<<"\nEnter denominator : "; cin>>d; while(d == 0)...

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
ADVERTISEMENT