@@ -145,22 +145,14 @@ for op in (:tocanonical,:fromcanonical,:tocanonicalD,:fromcanonicalD,:invfromcan
145145 @eval ($ op)(sp:: Space ,x... )= $ op (domain (sp),x... )
146146end
147147
148- mappoint (a:: Space ,b:: Space ,x)= mappoint (domain (a),domain (b),x)
149- mappoint (a:: Space ,b:: Domain ,x)= mappoint (domain (a),b,x)
150- mappoint (a:: Domain ,b:: Space ,x)= mappoint (a,domain (b),x)
151-
148+ _domain (s:: Space ) = domain (s)
149+ _domain (s) = s
150+ mappoint (a, b, x) = mappoint (map (_domain, (a, b, x))... )
152151
152+ _conversion_rule (a, b) = spacescompatible (a, b) ? a : NoSpace ()
153153
154154for FUNC in (:conversion_rule ,:maxspace_rule ,:union_rule )
155- @eval begin
156- function $FUNC (a,b)
157- if spacescompatible (a,b)
158- a
159- else
160- NoSpace ()
161- end
162- end
163- end
155+ @eval $ FUNC (a, b) = _conversion_rule (a, b)
164156end
165157
166158
250242# this is used primarily for addition of two funs
251243# that may be incompatible
252244union (a:: AmbiguousSpace , b:: AmbiguousSpace ) = b
253- union (a:: AmbiguousSpace , b:: Space ) = b
254- union (a:: Space , b:: AmbiguousSpace ) = a
245+ union_by_union_rule (a:: AmbiguousSpace , b:: Space ) = b
246+ union_by_union_rule (a:: Space , b:: AmbiguousSpace ) = a
255247
256248
257249function union_by_union_rule (a:: Space ,b:: Space )
@@ -287,12 +279,7 @@ function union(a::Space, b::Space)
287279 a ⊕ b
288280end
289281
290- union (a:: Space ) = a
291-
292- union (a:: Space ,b:: Space ,c:: Space ) = union (union (a,b),c)
293- union (a:: Space ,b:: Space ,c:: Space ,d:: Space... ) =
294- union (union (a,b),c,d... )
295-
282+ union (a:: Space , bs:: Space... ) = foldl (union, bs, init = a)
296283
297284# tests whether a Conversion operator exists
298285hasconversion (a,b) = maxspace (a,b) == b
0 commit comments