On Thu, Jul 01, 2004 at 08:27:49AM -0600, Chris Alvarez wrote:
> Now that I think, I am currently taking CS 330, structure of
> programming languages. We are learning Scheme, which is a variant of
> Lisp. Easy class, lots of homework but not that bad, CS 252 is a
> prerequisite for it.

I got my degree in Computer Engineering, but I wound up converting to
Computer Science.  CS252 was a prereq for the CS Master's program, so
I took it (scored an 'A' ;-).  Of all my textbooks from college, my
CS252 book is the only one I'll crack open and start reading, just for
the fun of it.

As a result, I am beginning a love afair with ML languages,
specifically Objective Caml.  Just look at this.  Sit, ponder, and
marvel at its elegance:

let rec list_max lst =
  match lst with
    [] -> failwith "list_max called on empty list"
  | [x] -> x
  | x :: remainder -> max x (list_max remainder)
;;

Oh, what exquisite joy fills my breast as I reflect upon the
meticulate serendipity of this algorithm!  The answer just ``pops
out'', as if by magic.  lst matches against the ``x :: remainder''
pattern, which are auto-aliased into the resulting action, inferring
all types!

Then we simply ask for the largest of either the head of the list, or
the largest value in the remainder of the list.  What determined the
largest value in the remainder of the list?  Why, the very function we
write!  We assume the question!  It's like an inductive proof, but it
actually implements an algorithm.  The best news is, tail-end
recursion in O'Caml gets compiled into an iterative code sequence (no
additional stack usage for each recursive step). Then you can compile
this as native machine code with ocamlopt (no virtual machine funny
business).  And you can't get any type cast exceptions, null pointer
references, or seg faults due to pointer problems.  The compiler just
won't let that kind of nonsense get past it.  So you get the best of
all worlds - memory usage, speed, elegance and beauty.

Now if you'll excuse me, I have to get back to the hell that is manual
memory management in C in the Linux kernel VFS layer...

Mike
.___________________________________________________________________.
                         Michael A. Halcrow                          
       Security Software Engineer, IBM Linux Technology Center       
GnuPG Fingerprint: 05B5 08A8 713A 64C1 D35D  2371 2D3C FDDA 3EB6 601D

If the self-serving bias is universal, how come I only see it in     
other people, but not myself? Answer that one! 

Attachment: pgp4YwCJI5gAt.pgp
Description: PGP signature

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to