Skip to content

2019-10: Odds & Evens

Given a vector of words, separate the words into two vectors – one containing all the words that have an odd number of letters and the other containing all the words that have an even number of letters.

💡 Hint: You may want to look into the dyadic form of the key operator X f⌸ Y.

Examples:

      (your_function) 'the' 'plan' 'is' 'great'   ⍝ ]box on is used to display theresult
┌───────────┬─────────┐
│┌───┬─────┐│┌────┬──┐│
││the│great│││plan│is││
│└───┴─────┘│└────┴──┘│
└───────────┴─────────┘
      (your_function) 'all' 'odd' ⍝ note the empty 2nd element of the result
┌─────────┬┐
│┌───┬───┐││
││all│odd│││
│└───┴───┘││
└─────────┴┘
      (your_function) 'only' 'even' 'here' ⍝ note the empty 1st element of the result
┌┬────────────────┐
││┌────┬────┬────┐│
│││only│even│here││
││└────┴────┴────┘│
└┴────────────────┘
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub