razetime / ngn-k-tutorial

An ngn/k tutorial.
https://razetime.github.io/ngn-k-tutorial/
195 stars 22 forks source link

Infocard is shown redundantly for range/odometer #6

Closed LyricLy closed 2 years ago

LyricLy commented 2 years ago

In chapter 2:

!x Range

Symbol: !

Args: ! number

Description: Array with numbers from 0 to x-1.

Providing range with a single number gives an expected result:

!5
0 1 2 3 4
!3 3
(0 0 0 1 1 1 2 2 2
0 1 2 0 1 2 0 1 2)

But what does that second result mean? ! generalizes to arrays of numbers, and this is called odometer. What this does is generate all indices to index into an array that has the dimensions described in x. Each column denotes one element.

!x Odometer

Symbol: !

Args: ! numeric_array

Description: Generate an array where each column denotes an index into an array which has dimensions x, in row-major order.

Odometer always generates an array of the length it is given, or in K's notation, #x.

In chapter 3:

! x Range / Odometer

Symbol: !

Arguments: ! number / numeric array

Description: range from 0 to x-1. Odometer is generalized range: generate indices for indexing into an array of shape x.

razetime commented 2 years ago

fixed in 2bd1af5