June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,28 @@
function _menu(items)
for (ind, item) in enumerate(items)
@printf " %2i) %s\n" ind item
end
end
_ok(::Any,::Any) = false
function _ok(reply::AbstractString, itemcount)
n = tryparse(Int, reply)
return isnull(n) || 0 ≤ get(n) ≤ itemcount
end
"Prompt to select an item from the items"
function _selector(items, prompt::AbstractString)
isempty(items) && return ""
reply = -1
itemcount = length(items)
while !_ok(reply, itemcount)
_menu(items)
print(prompt)
reply = strip(readline(STDIN))
end
return items[parse(Int, reply)]
end
items = ["fee fie", "huff and puff", "mirror mirror", "tick tock"]
item = _selector(items, "Which is from the three pigs: ")
println("You chose: ", item)