Sign in Join
Wiki copytemporary

Revision 1 of 2, by WikiArchive on 11-4-2026. The page as it is now.

In/fi

Varattu sana in testaa kuuloko kyseinen arvo joukkoon. Se palauttaa boolean arvon true jos arvo kuuluu joukkoon ja arvon false jos se ei kuulu kyseiseen joukkoon. In sanaa käytetään myös varatun sanan for kanssa for-in -silmukassa.

Esimerkki ohjelma

pascal
program projectin;
    uses SysUtils,TypInfo;
    
    type
      marja = (mustikka, lehtokuusama, puolukka, vadelma, lumimarja, mansikka);
      Berries = set of marja;
    var
       kori: Berries;
       someberry:marja;
       str:string;
       i:integer;
    begin
      kori := [];
      writeLn('Valitse jokin marja seuraavista marjoista koriin');
      repeat
        i:=1;
        for someberry in marja do
          begin
            Str := GetEnumName(TypeInfo(marja),ord(someberry));
            writeln(i,' : ',Str);
            inc(i);
          end;
        writeln('0 : poistu ');
        writeln;
        readln (i);
        if i>0 then
          begin
            someberry  :=marja(i-1);
            Include(kori,someberry);
          end;
      until  i=0;
      if (lehtokuusama in kori) or (lumimarja in kori) then
       begin
         writeln ('Sinulla on myrkyllisiä marjoja korissasi');
         if lehtokuusama in kori then
           writeln ('Korissasi on myrkyllinen lehtokuusama!') ;
         if lumimarja in kori then
           writeln ('Korissasi on myrkyllinen lumimarja!');
       end;
      writeln('Joten sinulla oli nämä marjat korissasi:');
      for someberry in kori do
      begin
        Str := GetEnumName(TypeInfo(marja),ord(someberry));
        writeln(Str);
      end;
      readln ;
    end.

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.