Merge branch 'stable-2.0'
[bpt/guile.git] / module / language / elisp / boot.el
index 0b2fc88..f55722a 100644 (file)
 
 ;;; Sequences
 
-(fset 'length (@ (guile) length))
+(defun length (sequence)
+  (funcall (if (listp sequence)
+               (@ (guile) length)
+             (@ (guile) generalized-vector-length))
+           sequence))
 
 (defun mapcar (function sequence)
   (funcall (@ (guile) map) function sequence))
 
 (defun format* (stream string &rest args)
   (apply (@ (guile) format) stream string args))
+
+(defun send-string-to-terminal (string)
+  (princ string))
+
+(defun read-from-minibuffer (prompt &rest ignore)
+  (princ prompt)
+  (let ((value (funcall (@ (ice-9 rdelim) read-line))))
+    (if (funcall (@ (guile) eof-object?) value)
+        ""
+      value)))
+
+(defun prin1-to-string (object)
+  (format* nil "~S" object))
+
+;; Random number generation
+
+(defvar %random-state (funcall (@ (guile) copy-random-state)
+                               (@ (guile) *random-state*)))
+
+(defun random (&optional limit)
+  (if (eq limit t)
+      (setq %random-state
+            (funcall (@ (guile) random-state-from-platform))))
+  (funcall (@ (guile) random)
+           (if (wholenump limit)
+               limit
+             (@ (guile) most-positive-fixnum))
+           %random-state))