3 ms·
if you insist on verbose names, they're always an option in K: west_scan : |\ A east_scan : ||\| A water_level : west
by RodgerTheGreat 2y ago
if you insist on verbose names, they're always an option in K:
west_scan : |\ A
east_scan : ||\| A
water_level : west_scan & east_scan
height_water_column : water_level - A
max_height : |/ height_water_column
total_water : +/ height_water_column
- chrispsn 2y agoAdding to RodgerTheGreat's comment: for me, k's power is its rich set of adverbs that are convenient to write. Notice that aside from reverse (monadic |), all verb symbols in the above code are in most other languages (max as |, min as &, plus as +, minus as -). Adverbs (such as / for reduce and \ for scan-reduce) make the symbols we already have more generally applicable. I think a language could go a long way with a small set of basic arithmetic symbols alongside a rich set of adverb symbols.
- RodgerTheGreat 2y agoAnd perhaps further worth noting, the reason K uses dyadic & and | for minimum and maximum (respectively) is because logical AND and logical OR are identical to minimum and maximum if the arguments happen to be boolean (0/1). The notation and selection of primitives illustrate a useful and memorable symmetry.