gevaux20.sl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. % GEVAUX20.SL.21
  2. % Auxiliary functions for PSL version of GEV.
  3. % GSN 07 March 83
  4. % Interlisp Substring function.
  5. (de substring (string first last)
  6. (cond ((not (stringp string)) (setq string (gevstringify string))))
  7. (cond ((minusp first)
  8. (setq first (add1 (plus (add1 (size string)) first)))))
  9. (cond ((minusp last)
  10. (setq last (add1 (plus (add1 (size string)) last)))))
  11. (subseq string (sub1 first) last) )
  12. % Make a string out of anything
  13. (de gevstringify (x)
  14. (cond ((stringp x) x)
  15. (t (bldmsg "%p" x))))
  16. % Concatenate an arbitrary number of items
  17. (de concatn (l)
  18. (cond ((null l) "")
  19. ((null (cdr l)) (gevstringify (car l)))
  20. (t (concat (gevstringify (car l)) (concatn (cdr l))))))
  21. (de concatln (l)
  22. (cond ((null l) "")
  23. ((null (cdr l)) (gevstringify (eval (car l))))
  24. (t (concat (gevstringify (eval (car l))) (concatln (cdr l))))))
  25. (df concatl (concatlarg) (concatln concatlarg))
  26. (de gevconcat (l) (concatn l))
  27. (de dreverse (l) (reversip l))
  28. (de mkatom (s) (intern s))
  29. (de gevputd (fn form)
  30. (put fn 'gloriginalexpr (cons 'lambda (cdr form)))
  31. (put fn 'glcompiled nil)
  32. (remd fn)
  33. (putd fn 'macro '(lambda (gldgform) (glhook gldgform))))
  34. % Apply a function to arguments, Glisp-compiling first if needed.
  35. (de gevapply (fn args)
  36. (cond ((and (atom fn)
  37. (or (null (get fn 'glcompiled))
  38. (not (eq (getddd fn) (get fn 'glcompiled)))))
  39. (glcc fn)
  40. (apply fn args))
  41. (t (apply fn args))))