From e097977f9e08691bbf7da54ce6437d522721b54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ois=C3=ADn=20Mac=20Fheara=C3=AD?= Date: Sat, 13 Jan 2024 09:37:27 +0000 Subject: [PATCH 1/3] Projections: Add alternative version with partial application shorthand --- 04-index-apply.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/04-index-apply.md b/04-index-apply.md index d08273e..0503625 100644 --- a/04-index-apply.md +++ b/04-index-apply.md @@ -180,6 +180,13 @@ To fix this, we should instead pass `a` via projection: as compared to assigning to `a` globally (`f:{a::x;{a+y}}`), this keeps data within the function, and makes the function side-effect free. This is not only useful in K, but helps for any programming task in general. +We can also express this using the shorthand for partial application: + +``` + f:{a:x;+[a;]}[1] + f[3] +4 +``` Now, if you remember from the beginning of this chapter, functions, arrays and dictionaries are all treated the same way in K. So projections can *also* apply to arrays and dictionaries! From 06f2ed3b006702bb445a827eb7ab4f718a35e57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ois=C3=ADn=20Mac=20Fheara=C3=AD?= Date: Sun, 14 Jan 2024 17:37:49 +0000 Subject: [PATCH 2/3] Typo --- 04-index-apply.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/04-index-apply.md b/04-index-apply.md index 0503625..be418b2 100644 --- a/04-index-apply.md +++ b/04-index-apply.md @@ -204,7 +204,7 @@ For an array, a projection will take all elements from the nth dimension of an a 1 4 7 ``` -For dictonaries, it will index into each nested dictionary within, and pull out the respective values: +For dictionaries, it will index into each nested dictionary within, and pull out the respective values: ``` (1 2 3!(3#,1 2 3!4 5 6))[;2] 1 2 3!5 5 5 From 8599e5b2c77fa0e6dfd0382d91889abeb4bd79c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ois=C3=ADn=20Mac=20Fheara=C3=AD?= Date: Fri, 2 Feb 2024 21:20:58 +0000 Subject: [PATCH 3/3] Fix Markdown table (pandoc needs a blank line above) --- 06-numbers-and-logic.md | 1 + 1 file changed, 1 insertion(+) diff --git a/06-numbers-and-logic.md b/06-numbers-and-logic.md index f332fc4..842e005 100644 --- a/06-numbers-and-logic.md +++ b/06-numbers-and-logic.md @@ -72,6 +72,7 @@ signify the absence of a value, and generally denote a special value in a given where null values are found are in indexing, where an out of bounds index returns a null value, and in find. **Null Values for each data type** + | Type | Null | | ---- | ---- | |Integer | `0N` |