Advertisement
Guest User

Untitled

a guest
Nov 1st, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. `g` is a 'helper' `Dfn` (**D**efined **f**unctio**n**). It takes the length of the (right) argument and mixes the vector `aeiou` to itself that many times, yielding every possible combination of `[2, length(right arg)]` vowels.
  2.  
  3. `{⊃,/⌽(,\⌽)¨,\⌽⍵}` is another 'helper' `Dfn`. It takes the right argument and yields every substring in order.
  4.  
  5. (Thanks to @Adám for providing the correct form of the above functions)
  6.  
  7. Finally, we have:
  8.  
  9. {((⊆g⍵)∊{⊃,/⌽(,\⌽)¨,\⌽⍵}⍵)⊆g⍵} ⍝ Main function; argument ⍵ = 'abeoic'
  10. {((⊆g⍵) ) } ⍝ Monadic ⊆ encloses the results of g⍵ so they're interpreted as vectors instead of scalars.
  11. ∊ ⍝ Dyadic ∊ returns 1 for every index of the left argument that is in the right argument, and 0 otherwise.
  12. {⊃,/⌽(,\⌽)¨,\⌽⍵}⍵ ⍝ yields every substring of 'abeoic', in order.
  13. ⊆g⍵ ⍝ Dyadic ⊆ partitions the results of it's right argument g⍵ according to a boolean (in APL, 1 for true and 0 for false) vector, which is what the dyadic ∊ returns.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement