Verbs Classification - kevinlawler/kona GitHub Wiki

Verbs (semantic table)

Verbs in K β€” that's what operations in imperative languages are. When you add two numbers in Python, you use an operation "+" (plus).

Python 3.2 (r32:88445, Apr 15 2011, 11:09:05) 
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 12 + 23
35

Verbs in K serve the same purpose.

K Console - Enter \ for help
  12 + 23
35

Yeah, it's too simple, I agree πŸ˜„ . But wait! While verbs are similar to operators, they have some distinctions:

  • verbs in K have one-symbol length! Here is the full list: ~!@#$%^&*-_=+|.<>. Every symbol has its own meaning. The one difficulty is to remember all purposes…
  • verbs can be used in two modes β€” prefix and infix. Prefix usage is called "monadic", infix β€” "dyadic". One verb can have different meanings in monadic and dyadic usages.
  • though syntax seems complicated, semantic is rudimentary when you know the classification. Almost all verbs can be divided into 4 groups by method of data modification:
    • Generative verbs β€” they create data
    • Modifying verbs β€” they make changes to data and do not change data length
    • Transforming verbs β€” they modify data, change shape, replace with other data
    • Reflection verbs β€” take a look on data, examine shape, result of operation is only one data item

Almost all the features and all K verbs have analogues in other languages, but only in APL-based they have 1-char-long syntax. This saves time for "parse-interpret" process.

Generation β€” creates new enumerations

  • ! monadic β€” enumerate
  • # dyadic n#m β€” fill

Modification β€” make modification of enumeration, do not change length

  • + dyadic β€” add
  • * dyadic β€” multiply
  • % monadic, dyadic β€” divide
  • - monadic, dyadic β€” subtract
  • | monadic, dyadic β€” reverse, MAX/or
  • & diadic β€” AND/min
  • ^ diadic β€” power
  • ~ monadic β€” not
  • ! dyadic β€” mod/rotate
  • < dyadic β€” less
  • > dyadic β€” greater
  • = dyadic β€” equal
  • _ monadic β€” floor

Transform β€” make modification of enumeration, may change length, shape, meaning

  • + monadic β€” transpose
  • & monadic β€” where
  • = monadic β€” group
  • < monadic β€” grade up
  • > monadic β€” grade down
  • ? monadic β€” unique
  • , dyadic β€” join
  • _ dyadic β€” cut lower/reshape
  • # dyadic n#y β€” fill by list
  • # dyadic n#y, length of y > n β€” cut upper

Meta β€” returns one item or information on enumeration

  • * monadic β€” take first
  • # monadic β€” count
  • ^ monadic β€” shape
  • ~ dyadic β€” full equal
  • @ monadic, dyadic β€” atom/at
  • , monadic β€” create one item list
  • . dyadic β€” value at
  • ? dyadic x?n version β€” find