next up previous contents index
Next: Defining Functions Up: Introductory Scheme Previous: Control

Math Operations

 

  As has been described earlier, math functions are called in the same manner as all other functions: a list whose first element is a math operator, and the rest of whose elements are arguments to that operator. The following math operators are defined:

(+  tex2html_wrap_inline1082 )
Addition: returns tex2html_wrap_inline1084 .

 
		 (+ 2 3) 		  tex2html_wrap_inline972  		 5

(+ 1.5 2.35) tex2html_wrap_inline972 3.85

(-  tex2html_wrap_inline1082 )
Subtraction: returns tex2html_wrap_inline1092 .

 
		 (- 5 2) 		  tex2html_wrap_inline972  		 3

(- 2.7 1.3) tex2html_wrap_inline972 1.4

(*  tex2html_wrap_inline1082 )
Multiplication: returns tex2html_wrap_inline1100 .

 
		 (* 3 5) 		  tex2html_wrap_inline972  		 15

(* 1.5 2.5) tex2html_wrap_inline972 3.75

(/  tex2html_wrap_inline1082 )
Division: returns tex2html_wrap_inline1108 .

 
		 (/ 8 2) 		  tex2html_wrap_inline972  		 4

(/ 1.5 3) tex2html_wrap_inline972 0.5

(quotient  tex2html_wrap_inline1082 )
Integer division: returns the integer portion of tex2html_wrap_inline1108 .

 
		 (quotient 9 4) 		  tex2html_wrap_inline972  		 2

(quotient 9 3) tex2html_wrap_inline972 3

(remainder  tex2html_wrap_inline1082 )
Remainder: returns the remainder that results from the division of tex2html_wrap_inline1124 by tex2html_wrap_inline1126 , or tex2html_wrap_inline1128 .

 
		 (remainder 9 4) 		  tex2html_wrap_inline972  		 1

(remainder 9 3) tex2html_wrap_inline972 0

(sqrt  n)
Square root: returns tex2html_wrap_inline1136 .

 
		 (sqrt 4) 		  tex2html_wrap_inline972  		 2

(sqrt 2) tex2html_wrap_inline972 1.4142135623731

(expt  tex2html_wrap_inline1082 )
Exponentiation: returns tex2html_wrap_inline1144 .

 
		 (expt 2 3) 		  tex2html_wrap_inline972  		 8

(expt 4 0.5) tex2html_wrap_inline972 2



Steven J. Zeil
Tue Mar 4 14:36:27 EST 1997