From ok@atlas.otago.ac.nz  Mon Dec 18 00:11:00 2000
Received: from atlas.otago.ac.nz (atlas.otago.ac.nz [139.80.32.250])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id AAA07259
	for <prolog@swi.psy.uva.nl>; Mon, 18 Dec 2000 00:10:59 +0100 (MET)
Received: (from ok@localhost)
	by atlas.otago.ac.nz (8.9.3/8.9.3) id MAA02079;
	Mon, 18 Dec 2000 12:11:18 +1300 (NZDT)
Date: Mon, 18 Dec 2000 12:11:18 +1300 (NZDT)
From: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
Message-Id: <200012172311.MAA02079@atlas.otago.ac.nz>
To: prolog@swi.psy.uva.nl, ra27946@scs.ubbcluj.ro
Subject: Re:  [SWIPL] Input numbers

Rastei Amelia Viorela  <ra27946@scs.ubbcluj.ro> writes:
(edited)
	I want to read integers from the standard input.	
	I tried

	?-readln(X).
	|: 2 3
	X=[2,3].
	
I prefer library(read_constant) in the Quintus library, but since I wrote
it, that's no surprise.

	How can I use the values 2,3  separately?

You have a list X = [2,3].
You extract values from *this* list the same way you extract values
from *any* list, namely by unification.  So

    ?- readln([A,B]).
    |: 2 3
    A = 2
    B = 3 

Or	?- readln(X), X = [A,B|_].
    |: 31 41 59
    X = [31,41,59]
    A = 31
    B = 41

	Is X a list of numbers?
	So I can use the functions nth1 or nth0??? 
	
It is a possibly empty list of tokens.
    ?- readln(X).
    |: 'Twas brillig and the slithey toves did gyre and gimble in the wabe.

    X = ['\'', 'Twas', brillig, and, the, slithey, toves, did, gyre, and|...] 

A token is a number, a stretch of letters, or a punctuation mark.
	 
You can use {nth0,nth1}/3 on this list, but why would you?
Why not just write down a list with variable names for the responses
you do want and underscores for the ones you don't?

