How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the PicoLisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the PicoLisp programming language

Table of Contents

Problem Statement

Obtain a valid   Y   or   N   response from the keyboard. The keyboard should be flushed, so that any outstanding key-presses are removed, preventing any existing   Y   or   N   key-press from being evaluated. The response should be obtained as soon as   Y   or   N   are pressed, and there should be no need to press an   enter   key.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the PicoLisp programming language

Source code in the picolisp programming language

(de yesno ()
   (loop
      (NIL (uppc (key)))
      (T (= "Y" @) T)
      (T (= "N" @)) ) )

  

You may also check:How to resolve the algorithm Write entire file step by step in the Delphi programming language
You may also check:How to resolve the algorithm Find the last Sunday of each month step by step in the F# programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the TXR programming language
You may also check:How to resolve the algorithm Currying step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Move-to-front algorithm step by step in the Phix programming language