Task

Select certain elements from an Array into a new Array in a generic way.



To demonstrate, select all even numbers from an Array.

As an option, give a second solution which filters destructively,
by modifying the original Array rather than creating a new Array.




  [ [] ]'[ rot
    witheach
      [ tuck over do iff
          [ dip [ nested join ] ]
        else nip ]
    drop ]                        is only    ( [ --> [ )
 
  [ 1 & not ]                     is even    ( n --> b )
 
  [] 10 times [ 10 random join ]
  say "Ten arbitrary digits: "   dup       echo cr
  say "Only the even digits: "   only even echo cr