John Smith commited on 2021-355 23:09:26
Showing 1 changed files, with 19 additions and 0 deletions.
Before this, prompts from the same card that all needed review would be reviewed right after each other, tempting the user to remember parts of the card in working memory, rather than recalling from long-term memory.
| ... | ... |
@@ -23,6 +23,24 @@ local function clear() |
| 23 | 23 |
io.write("\x1bc")
|
| 24 | 24 |
end |
| 25 | 25 |
|
| 26 |
+--[[ |
|
| 27 |
+ returns a shuffled version of the table, |
|
| 28 |
+ destroying the table in-place |
|
| 29 |
+ adapted from |
|
| 30 |
+ https://stackoverflow.com/q/55192727 |
|
| 31 |
+]] |
|
| 32 |
+local function shuffle(t) |
|
| 33 |
+ local ret = {}
|
|
| 34 |
+ local ci = 1 |
|
| 35 |
+ while #t > 0 do |
|
| 36 |
+ local ri = math.random(1, #t) |
|
| 37 |
+ ret[ci] = t[ri] |
|
| 38 |
+ table.remove(t, ri) |
|
| 39 |
+ ci = ci + 1 |
|
| 40 |
+ end |
|
| 41 |
+ return ret |
|
| 42 |
+end |
|
| 43 |
+ |
|
| 26 | 44 |
--[[ |
| 27 | 45 |
check action based on first command-line argument; |
| 28 | 46 |
if nothing valid given, default to help |
| ... | ... |
@@ -95,6 +113,7 @@ elseif action == "r" then |
| 95 | 113 |
end |
| 96 | 114 |
end |
| 97 | 115 |
end |
| 116 |
+ ctrt = shuffle(ctrt) |
|
| 98 | 117 |
io.write(string.format( |
| 99 | 118 |
"%d prompts are ready for review.\nHow many to review in this session? ", #ctrt |
| 100 | 119 |
)) |
| 101 | 120 |