Skip to content

Commit 81db9ac

Browse files
committed
Bring tutorial up to date.
1 parent fd33285 commit 81db9ac

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ examples/export/array
2828
hie.yaml
2929
Manifest.toml
3030
julia/deps/build.log
31+
examples/t10k-images-idx3-ubyte
32+
examples/t10k-labels-idx1-ubyte

examples/tutorial.dx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ mean y
121121
'## Typed indexing
122122

123123
' The use of typed indices lets you do really neat things, but
124-
lets consider how it works. Critically, one cannot
124+
let's consider how it works. Critically, one cannot
125125
simply index an table with an integer.
126126

127127
r = x.(2 : Int)
@@ -375,10 +375,12 @@ imscolor2 = for b. for i. for j. for c:Channels.
375375
pixel in a tile grid pattern. See if you can figure out the other
376376
types.
377377

378-
def split {m n o v} (x: m=>v) : n=>o=>v =
378+
def split {m n o v} [Ix n, Ix o] (x: m=>v) : n=>o=>v =
379379
for i j. x.(ordinal (i,j)@_)
380380

381-
def imtile {a b n o p q v} (x: a=>b=>v) : n=>o=>p=>q=>v =
381+
def imtile {a b n o p q v}
382+
[Ix n, Ix o, Ix p, Ix q]
383+
(x: a=>b=>v) : n=>o=>p=>q=>v =
382384
for kh kw h w. (split (split x).h.kh).w.kw
383385

384386
im1 : Fin 2 => Fin 2 => Fin 14 => Fin 14 => Float32 = imtile ims.(0@_)
@@ -498,7 +500,7 @@ withState 10 $ \ state.
498500
integer tables (of type `n => Float32`).
499501

500502
:t tableMean
501-
> ((n:Type) ?-> (n => Float32) -> Float32)
503+
> ((n:Type) ?-> (Ix n) ?=> (n => Float32) -> Float32)
502504

503505
' If we try to apply `tableMean` to other types for get errors. For example,
504506
`tableMean` does not work when applied to a table of *pairs* of floats.
@@ -593,7 +595,7 @@ instance {v w} [VSpace v, VSpace w] VSpace (v & w)
593595

594596
Pixels = Fin 256
595597

596-
def bincount {a b} (inp : a => b) : b => Int =
598+
def bincount {a b} [Ix b] (inp : a => b) : b => Int =
597599
withState zero \acc .
598600
for i.
599601
v = acc!(inp.i)

0 commit comments

Comments
 (0)