RosettaCodeData/Task/Ordered-words/APL/ordered-words.apl

14 lines
512 B
APL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

resultlongest_ordered_words file_path
ffile_path ⎕NTIE 0 ⍝ open file
text⎕NREAD f 'char8' ⍝ read vector of 8bit chars
⎕NUNTIE f ⍝ close file
linestext~text(⎕UCS 10 13) ⍝ split into lines (\r\n)
⍝ filter only words with ordered characters
ordered_wordslines/{()}¨lines
⍝ find max of word lengths, filter only words with that length
resultordered_words/lengths=/lengths¨ordered_words