Talk:Menu: Difference between revisions

→‎going further: propose alternate J version
(→‎prompt user: Fix wiki stuff)
(→‎going further: propose alternate J version)
Line 178:
 
Finally, hypothetically speaking, both this writeup and the original code might be changed. For example, perhaps, instead of a single long line, a user would be more comfortable with a series of short definitions of (throwaway) words. [In my experience, this sort of thing can be a handy learning tool. But -- unless particularly relevant words are used -- it also introduces distracting complexities, instead of illuminating anything.]
 
:I'd prefer something like the following as being more readily parseable:
<lang j>
load 'misc'
displayMenu=: i.@# smoutput@,&":&> ' '&,&.>
makeMsg=: 'Choose a number 0..' , ': ',~ ":@<:@#
displayBadNumMsg=: [ smoutput bind 'Please choose a valid number!'
select=: ({::~ [: _&".@prompt makeMsg [ displayMenu) :: ($:@displayBadNumMsg)
</lang>
:--[[User:Tikkanz|Tikkanz]] 02:46, 15 October 2009 (UTC)
892

edits