maxima : appendix  union algo , version 1.0
peter.vlasschaert@gmail.com,13/11/2019

ref : C-code: Denis Constales UGent
=============================
use : only for integer input

#include<stdio.h>

int
main (void)
{
  int arr[20], i0, i, j, size;
  printf ("\nEnter array size : ");
  scanf ("%d", &size);
  printf ("\nAccept Numbers : ");
  for (i = 0; i < size; i++)
    scanf ("%d", &arr[i]);
  printf ("\nArray with Unique list  : ");
  i0 = 0;
  for (i = 0; i < size; i++)
    {
      j = 0;
      while (j < i && arr[j] != arr[i])
{
 j++;
}
      if (j >= i)
{
 if (i0 != i)
   arr[i0] = arr[i];
 i0++;
}
    }
  size = i0;
  for (i = 0; i < size; i++)
    {
      printf ("%d ", arr[i]);
    }

  return (0);

input element list
=============

p1:[Na,O,H,S,O];

p1 [1];

input : number of elements
====================

sz:5;

algo : union
----------------

ww: union_str(p1):=block([],i0:1,sz:length(p1),
          for i thru sz do
              (j:1,while j < i and p1[j] # p1[i] do j:j+1,
               if j >= i then (if i0 # i then p1[i0]:p1[i],i0:i0+1)),sz:i0-1,
          l:firstn(p1,sz),return(l))$

rem:
general => j:1,while j < i and p1[j] # p1[i] do
( j:j+1)
local      =>  for i:1 while j < i and p1[j] # p1[i] do
( j:j+1)

rem :
firstn ?

? firstn;

example : firstn
============

firstn(p1,2);

output : element list

union_str(p1);

grind(ww);

rem : print

print(p1);

rem :  relation between :listify & setify
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
same : algo above.

input list
======

p1;

p2:setify(p1);

result
=====

p3:listify(p2);