how to do exponentiation and ceiling in standard ml? in ruby

To perform exponentiation in Standard ML, you can use the Math.pow function from the Real structure. Here's an example:

val result = Math.pow(2.0, 3.0)
32 chars
2 lines

This will raise 2 to the power of 3 and store the result in the result variable. Note that the arguments and the result are of type real.

To round a real number up to the nearest integer (ceiling), you can use the Real.ceil function. Here's an example:

val result = Real.ceil(3.14)
29 chars
2 lines

This will round 3.14 up to 4. The result will be of type real.

In Ruby, you can achieve exponentiation using the ** operator. Here's an example:

main.rb
result = 2 ** 3
16 chars
2 lines

This will raise 2 to the power of 3 and store the result in the result variable.

To find the ceiling of a number in Ruby, you can use the ceil method from the Float class. Here's an example:

main.rb
result = 3.14.ceil
19 chars
2 lines

This will round the number 3.14 up to 4 and store the result in the result variable.

gistlibby LogSnag