On Mon, Mar 26, 2001 at 10:50:09AM -0500, Uri Guttman wrote:
>   SC> it?  That is, @s = sort { f($a) <=> f($b) } @t
> 
> because that would require the PSI::ESP module which isn't working
> yet. how would perl intuit exactly the relationship between the records
> and the keys extraction and comparison? the ST defines that by the first
> map and the comparison callback. just providing the comparison would
> entail perl parsing an arbitrarily complex piece of code and then
> autognerating the map that would produce an anon array that fits it. not
> a simple task. 

No, it wouldn't, don't be silly. The ST can always be generalized to 

    ST(data, func, compare) =
    map { $_->[0] } sort { compare($a->[1], $b->[1]) } map { [$_, f($_)] } data

In fact, you can implement it in LISP just like that:

(defun Schwartzian (list func compare)
  (mapcar
   (lambda (x) (car x))
   (sort
    (mapcar
     (lambda (x) (cons x (funcall func x)))
     list
     )
    (lambda (x y) (funcall compare (cdr x) (cdr y)))
    )
   )
  )

Do you see any ESP there? Do you see any parsing of arbitrary pieces of
code? No, me neither.

-- 
SM is fun.  ADSM is not.
"Safe, Sane, Consensual"... three words that cannot used to describe
ADSM.
    - Graham Reed, sdm.

Reply via email to