Implement SQRT function
[jscl.git] / src / numbers.lisp
index 3490df9..a386972 100644 (file)
@@ -13,6 +13,8 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with JSCL.  If not, see <http://www.gnu.org/licenses/>.
 
+(/debug "loading numbers.lisp!")
+
 ;;;; Various numeric functions and constants
 
 (macrolet ((def (operator initial-value)
@@ -81,7 +83,7 @@
 (macrolet ((def (name comparison)
              `(defun ,name (x &rest xs)
                 (dolist (y xs) 
-                  (unless (,comparison x (car xs))
+                  (when (,comparison y x)
                     (setq x y)))
                 x)))
   (def max >)
@@ -92,6 +94,8 @@
 (defun expt (base power) (expt base              power))
 (defun exp  (power)      (expt 2.718281828459045 power))
 
+(defun sqrt (x) (sqrt x))
+
 (defun gcd-2 (a b)
   (if (zerop b)
       (abs a)