Last active
October 26, 2023 21:36
-
-
Save justin2004/e9027f4052ed31dfe786d49fa7f5cdb3 to your computer and use it in GitHub Desktop.
Using APL in shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I needed to find the length of the longest filename | |
$ ls -1 *ttl | |
DatesAndTimes.ttl | |
download.ttl | |
exercise_log.ttl | |
gistHR0.2.0.ttl | |
nobel-prize-metaphacts-shacl-ontology.ttl | |
sample.ttl | |
SemArts2.0.0.ttl | |
visits_no_bnodes.ttl | |
visits.ttl | |
ABC-architecture.ttl | |
# A classic way | |
$ ls -1 *ttl | wc --max-line-length | |
41 | |
# Note that you kind of just have to know about this command (wc) and this particular option (--max-line-length). | |
# You can't just stumble into it by building it up from primitives. | |
# Using APL in the shell (https://github.com/justin2004/apl_in_the_shell) | |
$ ls -1 *ttl | apl '⌈/≢¨' - | |
41 | |
# In APL: ⌈/≢¨ means for each (¨) thing, take the tally (≢), then do a maximum (⌈) reduce (/) | |
# The "-" argument is a standard way of saying "use stdin as input" | |
# Note how I didn't have to discover the whole string '⌈/≢¨' in the first instance -- instead | |
# I was able to build it up from the primitives incrementally. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment