--* From SMWATT%WATSON.vnet.ibm.com@yktvmh.watson.ibm.com  Fri May 28 21:40:43 1993
--* Received: from yktvmh.watson.ibm.com by radical.watson.ibm.com (AIX 3.2/UCB 5.64/900524)
--*           id AA16619; Fri, 28 May 1993 21:40:43 -0400
--* Received: from watson.vnet.ibm.com by yktvmh.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 0818; Fri, 28 May 93 21:41:14 EDT
--* Received: from YKTVMH by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.SMWATT.NOTE.VAGENT2.7511.May.28.21:41:13.-0400>
--*           for asbugs@watson; Fri, 28 May 93 21:41:13 -0400
--* Received: from YKTVMH by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id 7509; Fri, 28 May 1993 21:41:13 EDT
--* Received: from cyst.watson.ibm.com by yktvmh.watson.ibm.com (IBM VM SMTP V2R3)
--*    with TCP; Fri, 28 May 93 21:41:13 EDT
--* Received: from spadserv.watson.ibm.com by cyst.watson.ibm.com (AIX 3.2/UCB 5.64/900528)
--*   id AA32995; Fri, 28 May 1993 21:41:14 -0400
--* Received: by spadserv.watson.ibm.com (AIX 3.2/UCB 5.64/900524)
--*           id AA14877; Fri, 28 May 1993 21:43:10 -0400
--* Date: Fri, 28 May 1993 21:43:10 -0400
--* From: smwatt@spadserv.watson.ibm.com (Stephen Watt)
--* X-External-Networks: yes
--* Message-Id: <9305290143.AA14877@spadserv.watson.ibm.com>
--* To: asbugs@watson.ibm.com
--* Subject: Does not treat the if in the repeat as no-value mode so it rejects it for having different types on branches. [runt.as][v28.B, v28.C]

--@ Fixed  by:  SMW   Wed Oct 13 18:58:51 1993 
--@ Tested by:  if0.as 
--@ Summary:    modified titdnIf 


#include "aslib"
#library DemoLib "asdem"

import DemoLib
import IntegerPrimesPackage
import SingleInteger
import Integer
import Foreign(C): with
	gets: String -> String
	atoi: String -> SingleInteger

-- Read a list of small primes.
-- Non-primes are ignored and 0 ends the list.

readPrimes(): List SingleInteger ==
	print("Please enter primes, one per line.")()
	print("Use a value of 0 to end the list.")()

	l: List SingleInteger := []
	s: String := new 200
	repeat
		print("Enter a prime: ")()
		gets s
		n := atoi s
		n = 0 => break
		if not prime?(n::Integer) then
			print("...ignoring the non-prime ")(n)()
		else
			l := cons(n, l)
	print("Got the list of primes: ")(l)()
	l

readPrimes()

FieldRecord ==> Record(name: String, field: Field)
import FieldRecord

getSomeFields(): List FieldRecord ==
	import SingleInteger
	import Format
	lf: List FieldRecord :=
	  [["Rational", Ratio Integer],
           ["Float", Float],
	   ["Complex DoubleFloat", Complex DoubleFloat]]
	lp: List SingleInteger := readPrimes()

	s: String := new 200
	for p in lp repeat
		format(p, s, 1)
		lf := cons([concat("Z mod ", s), SmallPrimeField p], lf)
	lf
	

showField(name: String, K: Field): () ==
	z: K := 1/(1+1+1)
	print("The value of 1/3 in the ")(name)(" field is ")(z)()

lf1: List FieldRecord := getSomeFields()

for fr in lf1 repeat showField(fr.name, fr.field)
 
