From: mpeever on
I've been experimenting with CL scripting for about a year now. We've
got a significant amount of SBCL code working in our Legato Networker
environment. We've started small, but so far we're really happy with
it. I'm currently considering the benefits of replacing some
significant Perl processes in CL. There are some pending changes that
are much more daunting in Perl than CL.

We wrote a quick-and-dirty toolkit to clean up some of the OS
interfacing: we've more or less tried to imitate Perl's operators. Our
toolkit appears to work on SBCL, CCL, and ECL. Making it support
multiple implementations was important, as we're still very much in
pilot mode: we may yet have to make some drastic changes and we need
to be able to move quickly.

We've been taking advantage of the core-dump facilities in CL
implementations for code roll-outs. It makes updates and changes very
simple, especially once we hit a critical mass point.

I'm very interested to hear about your experiences.
From: W. James on
Tamas K Papp wrote:

> (defun random-string (length &optional (allowed-chars
> "01234567890abcdef"))
> "Return a random string of given length, composed from allowed-chars."
> (let* ((n (length allowed-chars))
> (string (make-string length)))
> (dotimes (i length)
> (setf (aref string i) (aref allowed-chars (random n))))
> string))

In allowed-chars, "0" occurs twice. Why?

Commune-Lisp, like COBOL, has a magical ability to bloat the simplest task.

def random_string length, chars = "0123456789abcdef"
(1 .. length).map{ chars[ rand( chars.size ), 1 ] }.join
end


Guy L. Steele, Jr., July 1989:

I think we may usefully compare the approximate number of pages
in the defining standard or draft standard for several
programming languages:

Common Lisp 1000 or more
COBOL 810
ATLAS 790
Fortran 77 430
PL/I 420
BASIC 360
ADA 340
Fortran 8x 300
C 220
Pascal 120
DIBOL 90
Scheme 50

--

From: W. James on
Tamas K Papp wrote:

> ;;;; This simple scripts saves standard input to a randomly generated
> ;;;; file (starting with *base-path*) and then calls a browser to
> ;;;; open this file (current setup obviously Ubuntu/Debian specific).
>
> ;; working with strings instead of pathnames
> (defparameter *base-path* "/tmp/savebody")
>
> ;; browser
> (defparameter browser "sensible-browser")
>
> (defun random-string (length &optional (allowed-chars
> "01234567890abcdef"))
> "Return a random string of given length, composed from allowed-chars."
> (let* ((n (length allowed-chars))
> (string (make-string length)))
> (dotimes (i length)
> (setf (aref string i) (aref allowed-chars (random n))))
> string))
>
> (defun open-unique (&key (base-path *base-path*)
> (random-length 10)
> (max-tries 100))
> "Return stream and path."
> (tagbody
> top
> (when (minusp max-tries)
> (error "could not open random file - this should not happen"))
> (let* ((random-path (concatenate 'string base-path (random-string
> random-length)))
> (stream (open random-path :direction :output :if-exists nil
> :if-does-not-exist :create)))
> (unless stream
> (decf max-tries)
> (go top))
> (return-from open-unique (values stream random-path)))))
>
> (defun copy-stream (input output)
> "Copy input to output. No error handling."
> ;; is this the right way to do it?
> (tagbody
> top
> (multiple-value-bind (line missing-newline-p) (read-line input
> nil nil)
> (when line
> (if missing-newline-p
> (write-string line output)
> (write-line line output))
> (go top)))))

What?

What language is so crude and primitive that goto is required?

>
> (multiple-value-bind (stream path) (open-unique)
> ;; open file and copy stdin
> (unwind-protect
> (copy-stream *standard-input* stream)
> (close stream))
> ;; open browser
> (let ((args (list (concatenate 'string "file://" path))))
> #+sbcl (sb-ext:run-program browser args
> :search t :wait nil)
> #+ecl (ext:run-program browser args)))
>

# Write stdin to a file whose name is randomly generated.

def random_string length, chars = "0123456789abcdef"
(1 .. length).map{ chars[ rand( chars.size ), 1 ] }.join
end

100.times{ file = random_string( 10 )
if not File.exists?( file )
File.open( file, "w" ){|f| f.puts gets(nil) }
exit
end }

puts "Failed to open output file."



--

From: Juanjo on
On Dec 5, 9:39 pm, "W. James" <w_a_x_...(a)yahoo.com> wrote:
> Tamas K Papp wrote:
> > (defun random-string (length &optional (allowed-chars
> > "01234567890abcdef"))
> >   "Return a random string of given length, composed from allowed-chars."
> >   (let* ((n (length allowed-chars))
> >          (string (make-string length)))
> >     (dotimes (i length)
> >       (setf (aref string i) (aref allowed-chars (random n))))
> >     string))
>
> In allowed-chars, "0" occurs twice.  Why?
>
> Commune-Lisp, like COBOL, has a magical ability to bloat the simplest task.
>
> def random_string length, chars = "0123456789abcdef"
>   (1 .. length).map{ chars[ rand( chars.size ), 1 ] }.join
> end

Ah, yes, cons an interval and a list to then cons a string. And so
readable as well

(defun random-string (length &optional (allowed-chars
"01234567890abcdef"))
(map-into (make-string length)
#'(lambda () (char allowed-chars (random (length allowed-
chars))))))

> I think we may usefully compare the approximate number of pages
> in the defining standard or draft standard for several
> programming languages:

Why don-t you look for the amount of pages trying to explain people
what those specification really meant?
From: Raffael Cavallaro on
On 2009-12-05 16:20:50 -0500, "W. James" <w_a_x_man(a)yahoo.com> said:

> What language is so crude and primitive that goto is required?

what language is so crude and primitive that its copious syntax looks
like line noise?
--
Raffael Cavallaro

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8
Prev: 3 questions about arrays
Next: Is President Obama a Nice Guy?