User input/Text: Difference between revisions
Content added Content deleted
(Add Logtalk implementation) |
|||
Line 562: | Line 562: | ||
make "input readword ; in: string 75000 |
make "input readword ; in: string 75000 |
||
show :input ; string 75000</lang> |
show :input ; string 75000</lang> |
||
=={{header|Logtalk}}== |
|||
Using an attom representation for strings and type-check failure-driven loops: |
|||
<lang logtalk> |
|||
:- object(user_input). |
|||
:- public(test/0). |
|||
test :- |
|||
repeat, |
|||
write('Enter an integer: '), |
|||
read(Integer), |
|||
integer(Integer), |
|||
!, |
|||
repeat, |
|||
write('Enter an atom: '), |
|||
read(Atom), |
|||
atom(Atom), |
|||
!. |
|||
:- end_object. |
|||
</lang> |
|||
Output: |
|||
<lang text> |
|||
| ?- user_input::test. |
|||
Enter an integer: 75000. |
|||
Enter an atom: 'Hello world!'. |
|||
yes |
|||
</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |