1 ;;; -*- LISP -*- 5 October 1979
5 ;;; Setup for the Macsyma world
7 ;; Make PARALLEL(arg1,arg2,...,argN) mean arg1 | arg2 | arg3 | ... | argN
9 (meval '(($ALIAS
) $PARALLEL
&/|
))
11 ;; Make "|" be an N-ary operator
15 ;; Redefine label chars...
20 (SETQ $INCHAR
'$IN $OUTCHAR
'$OUT $LINECHAR
'$AUX
)
26 ;; (MAKE-CIRCULAR-LIST <list>) returns a pointer to a circular list with
29 (DEFUN MAKE-CIRCULAR-LIST MACRO
(FORM)
30 `((LAMBDA (X) (NCONC X X
)) (APPEND ,(CADR FORM
) NIL
)))
32 ;;; Define a "|" function which computes parallel resistances.
35 (LET ((COMPONENTS (LISTIFY N
)))
37 ((MTIMES) ,@COMPONENTS
)
38 ((MPLUS) ,@(PERMUTATIONS-OF-<N-1
> N COMPONENTS
)))))
40 (DEFUN PERMUTATIONS-OF-
<N-1
> (N-COMPONENTS COMPONENTS-LIST
)
41 (DO ((RETURN-VALUE ())
43 (CYCLE (MAKE-CIRCULAR-LIST COMPONENTS-LIST
)
45 ((> I N-COMPONENTS
) RETURN-VALUE
)
46 (PUSH (DO ((I 2.
(1+ I
))
47 (RETURN-VALUE () (CONS (CAR L
) RETURN-VALUE
))
50 (CONS '(MTIMES) RETURN-VALUE
)))