comp.lang.ada
 help / color / mirror / Atom feed
From: brh@cray.com (Brian Hanson)
Subject: Re: No top schools use Ada
Date: 1995/04/20
Date: 1995-04-20T00:00:00+00:00	[thread overview]
Message-ID: <1995Apr20.105933.18413@driftwood.cray.com> (raw)
In-Reply-To: dewar.798344756@gnat

In article 798344756@gnat, dewar@cs.nyu.edu (Robert Dewar) writes:
> Regarding using Ada to teach computer science
>  Scheme is a different issue: to me it is limiting to live only in the
>  functional world. For example, today I was presenting heapsort. The
>  essence of this algorithm is the in place tree mapping, that's what
>  makes the algorithm interesting.
Huh?  Over in the comp.lang.scheme there have been long drawn out arguments
about how scheme is not really a functional language as it is not a pure
functional language.

I have written a number of significant programs in scheme and never
really written in functional style.

Scheme is a lean and elegant lisp.

;; The following sorts are short but horribly inefficient

(define (insertion-sort a)
  (do ((i 1 (+ i 1)))
      ((>= i (vector-length a)) a)
    (do	((v (vector-ref a i) v)
	 (j i (- j 1)))
      ((or (< j 1) (< (vector-ref a (- j 1)) v))
       (vector-set! a j v))
      (vector-set! a j (vector-ref a (- j 1))))))

(define (swap! a i j)
  (let ((v (vector-ref a i)))
    (vector-set! a i (vector-ref a j))
    (vector-set! a j v)))

(define (bubble-sort a)
  (do ((i (- (vector-length a) 1) (- i 1)))
      ((< i 0) a)
    (do ((j 1 (+ j 1)))
	((> j i))
      (if (> (vector-ref a (- j 1)) (vector-ref a j))
	  (swap! a j (- j 1))))))

(define l (list 1 5 7 8 2 4 1 5 6 2))

(define (run sort a)
  (sort a)
  (display a)
  (newline))

(run insertion-sort (list->vector l))
(run bubble-sort (list->vector l))

$ vscm
> (load "../src/scm/sort.scm")
#(1 1 2 2 4 5 5 6 7 8)
#(1 1 2 2 4 5 5 6 7 8)
;value (after 170ms... comp: 0 (0 GC), exec: 170 (0 GC)):
#t
> 

-- 
-- Brian Hanson
-- brh@cray.com




  reply	other threads:[~1995-04-20  0:00 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3mq0jd$r10@kaiwan009.kaiwan.com>
     [not found] ` <D759Az.GHM@cs.fredonia.edu>
     [not found]   ` <NEWTNews.19974.798127420.cjames@cec-services-01>
1995-04-18  0:00     ` No top schools use Ada Jay M Martin
1995-04-20  0:00     ` Vladimir Vukicevic
1995-04-20  0:00     ` Norman H. Cohen
1995-04-20  0:00       ` cjames
1995-04-19  0:00   ` Michael Sperber [Mr. Preprocessor]
1995-04-19  0:00   ` Ian S Nelson
1995-04-19  0:00     ` Robert Dewar
1995-04-20  0:00       ` Brian Hanson [this message]
1995-04-20  0:00         ` Robert Dewar
1995-04-20  0:00       ` First Language Debate etc Deepak Kumar
1995-04-20  0:00         ` Robert Dewar
1995-04-21  0:00           ` Deepak Kumar
1995-04-19  0:00     ` No top schools use Ada Robert Dewar
1995-04-22  0:00   ` Chris Morgan
1995-04-19  0:00 ` Kenneth Almquist
1995-04-18  0:00   ` cjames
1995-04-19  0:00     ` Kenneth Almquist
     [not found] ` <3n10sv$i97@gopher.cs.uofs.edu>
1995-04-19  0:00   ` Fernando Mato Mira
1995-04-20  0:00 ` Which first-course languages? (was: What schools use Eiffel (was: No top schools use Ada)) ? Spencer Allain
1995-04-20  0:00   ` Scott Wheeler
1995-04-21  0:00   ` Neil Wilson
     [not found] ` <NEWTNews.27781.798049024.ir001168@cec-services-01>
     [not found]   ` <3mrg2c$onn@disunms.epfl.ch>
     [not found]     ` <tomkwongD76x5L.AED@netcom.com>
1995-04-19  0:00       ` Theodore Dennison
1995-04-19  0:00         ` Robert Dewar
1995-04-19  0:00         ` Theodore Dennison
1995-04-19  0:00           ` Scott Wheeler
1995-04-20  0:00             ` Robert Dewar
1995-04-21  0:00               ` Jeremiah S Patterson
1995-04-21  0:00           ` Scott Wheeler
1995-04-20  0:00         ` Robert Johnson
1995-04-20  0:00           ` Robert Dewar
1995-04-20  0:00         ` Which first-course languages? (was: What schools use Eiffel (was Geert Bosch
1995-04-21  0:00         ` Which first-course languages? (was: What schools use Eiffel (was: No top schools use Ada)) ? Des Kenny
1995-04-21  0:00           ` Robert Dewar
1995-04-20  0:00   ` What schools use Eiffel ? Igor Chudov
1995-04-21  0:00 ` Madison Cloutier
     [not found] <9504200153.AA25668@GNAT.CS.NYU.EDU>
1995-04-21  0:00 ` No top schools use Ada Ian S Nelson
1995-04-21  0:00   ` Jay M Martin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox