kill(all)$

appendix :maxima : recursion for ∩ and ∪, use unicode. version 1.0
peter.vlasschaert@gmail.com,04/07/2022

ref :https://unicode-table.com/en/search/?q=union+unicode

1e) part : How to use unicode in Maxima.
------------------------------------------------------

go to website :https://unicode-table.com/en/

∩ : ? intersection symbol.

1e step : input window website.

→ Unicode Character Table : intersection unicode  

2e step : search result (∩)

→ click intersection 

3e step: copy ( = red) → paste

→ ∩

analog :  ∪ (union),search :union unicode

2e) part : recursion (= explained , math → maxima)
--------------------------------------------------------------------

input : list 
--------

a =[a1,a2,a3,...,an] = [a1,rest(a)] = [first(a),rest(a)]
b =[b1,b2,b3,...,bn] = [b1,rest(b)] = [first(b),rest(b)]
[] = empty list

rem : LOWEST LEVEL otherwise  Error = "search : ∞ depth computations" 

a) Union : math → maxima

→  math : ∪

1e step : Lowest Level

→ [ ]  ∪ b =b;

2e step : new function = w

→ w = rest(a)  ∪ b 

3e step : result

→ first (a) ∈ w  → cons

→ maxima : ∪ (Denis solution)

w2(l1,l2):=if l1=[] then l2 else
                 if member(first(l1),w2(rest(l1),l2)) then
                   w2(rest(l1),l2)
                 else
                   cons(first(l1),w2(rest(l1),l2))$

grind(w2)$

b) Intersection : math → maxima

→  math : ∩

1e step : Lowest Level

→ [] ∩ b = ɸ

 ɸ = emptylist

2e step : new function = w

→  w = rest(a)  ∩  b 

3e step : condition

 → first(a) ∈ w                (1)
 → first(a) ∈ b → cons   (2)

if (1) and (2) result : false  then w

→ maxima : ∩ (Denis solution)

i(a,b) := if a=[ ] then [ ] else 
    block([w],w:i(rest(a),b),
    if member(first(a),w) then w
    else if 
             member(first(a),b)
    then 
             cons(first(a),w) 
    else 
             w)$

grind(i)$

---------------------------------------------------------------------------------------------------