Sign in Join
Wiki copytemporary

In/fi: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: In/fi

OldNewLine
1+[[Reserved word/fi|Varattu sana]] `in` testaa kuuloko kyseinen arvo [[Set/fi|joukkoon]]. Se palauttaa [[Boolean/fi|boolean]] arvon [ `true`](</index.php?title=True/fi&action=edit&redlink=1> "True/fi \(page does not exist\)") jos arvo kuuluu joukkoon ja arvon [[False|`false`]] jos se ei kuulu kyseiseen joukkoon. `In` sanaa käytetään myös varatun sanan [`for`](</index.php?title=For/fi&action=edit&redlink=1> "For/fi \(page does not exist\)") kanssa [[for-in loop|for-in -silmukassa]].
2+
3+## Esimerkki ohjelma
4+```
5+program projectin;
6+ uses SysUtils,TypInfo;
7+
8+ type
9+ marja = (mustikka, lehtokuusama, puolukka, vadelma, lumimarja, mansikka);
10+ Berries = set of marja;
11+ var
12+ kori: Berries;
13+ someberry:marja;
14+ str:string;
15+ i:integer;
16+ begin
17+ kori := [];
18+ writeLn('Valitse jokin marja seuraavista marjoista koriin');
19+ repeat
20+ i:=1;
21+ for someberry in marja do
22+ begin
23+ Str := GetEnumName(TypeInfo(marja),ord(someberry));
24+ writeln(i,' : ',Str);
25+ inc(i);
26+ end;
27+ writeln('0 : poistu ');
28+ writeln;
29+ readln (i);
30+ if i>0 then
31+ begin
32+ someberry :=marja(i-1);
33+ Include(kori,someberry);
34+ end;
35+ until i=0;
36+ if (lehtokuusama in kori) or (lumimarja in kori) then
37+ begin
38+ writeln ('Sinulla on myrkyllisiä marjoja korissasi');
39+ if lehtokuusama in kori then
40+ writeln ('Korissasi on myrkyllinen lehtokuusama!') ;
41+ if lumimarja in kori then
42+ writeln ('Korissasi on myrkyllinen lumimarja!');
43+ end;
44+ writeln('Joten sinulla oli nämä marjat korissasi:');
45+ for someberry in kori do
46+ begin
47+ Str := GetEnumName(TypeInfo(marja),ord(someberry));
48+ writeln(Str);
49+ end;
50+ readln ;
51+ end.
52+```
53+
54+---
55+*From the Free Pascal wiki, page "In/fi", as the Internet Archive kept it on 2025-02-09. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history