home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / icon / dos / src / tests / proto.icn < prev    next >
Text File  |  1992-02-09  |  2KB  |  157 lines

  1. #  This program contains samples of all the basic syntactic
  2. #  forms in Icon.
  3.  
  4. record three(x,y,z)
  5. record zero()
  6. record one(z)
  7.  
  8. global line, count
  9.  
  10. procedure main()
  11. end
  12. procedure expr1(a, b)
  13.    local x,y,z
  14.    static e1
  15.    initial e1 := 0
  16.    ()
  17.    {}
  18.    ();()
  19.    []
  20.    [,]
  21.    x.y
  22.    x[i]
  23.    x[i:j]
  24.    x[i+:j]
  25.    x[i-:j]
  26.    (,,,)
  27.    x(,,,)
  28.    x!y
  29.    not x
  30.    |x
  31.    !x
  32.    *x
  33.    +x
  34.    -x
  35. end
  36.  
  37. procedure expr2(a, b[])
  38.    .x
  39.    /x
  40.    =x
  41.    ?x
  42.    \x
  43.    ~x
  44.    @x
  45.    ^x
  46.    x \ i
  47.    x @ y
  48.    i ^ j
  49.    i * j
  50.    i / j
  51.    i % j
  52.    c1 ** c2
  53.    i + j
  54.    i - j
  55.    c1 ++ c2
  56.    c1 -- c2
  57.    s1 || s2
  58.    a1 ||| a2
  59.    i < j
  60.    i <= j
  61.    i = j
  62.    i >= j
  63.    i > j
  64.    i ~= j
  65.    s1 << s2
  66.    s1 == s2
  67.    s1 >>= s2
  68.    s1 >> s2
  69.    s1 ~== s2
  70.    x === y
  71.    x ~=== y
  72.    x | y
  73.    i to j
  74.    i to j by k
  75.    x := y
  76.    x <- y
  77.    x :=: y
  78.    x <-> y
  79.    i +:= j
  80.    i -:= j
  81.    i *:= j
  82. end
  83.  
  84. procedure expr3()
  85.    i /:= j
  86.    i %:= j
  87.    i ^:= j
  88.    i <:= j
  89.    i <=:= j
  90.    i =:= j
  91.    i >=:= j
  92.    i ~=:= j
  93.    c1 ++:= c2
  94.    c1 --:= c2
  95.    c1 **:= c2
  96.    s1 ||:= s2
  97.    s1 <<:= s2
  98.    s1 <<=:= s2
  99.    s1 ==:= s2
  100.    s1 >>=:= s2
  101.    s1 >>:= s2
  102.    s1 ~==:= s2
  103.    s1 ?:= s2
  104.    a1 |||:= a2
  105.    x ===:= y
  106.    x ~===:= y
  107.    x &:= y
  108.    x @:= y
  109.    s ? x
  110.    x & y
  111.    create x
  112.    return
  113.    return x
  114.    suspend x
  115.    suspend x do y
  116.    fail
  117. end
  118.  
  119. procedure expr4()
  120.    while e1 do break
  121.    while e1 do break e2
  122.    while e1 do next
  123.    case e of {
  124.      x:   fail
  125.      (i > j) | 1    :  return
  126.      }
  127.    case size(s) of {
  128.      1:   1
  129.      default:  fail
  130.      }
  131.    if e1 then e2
  132.    if e1 then e2 else e3
  133.    repeat e
  134.    while e1
  135.    while e1 do e2
  136.    until e1
  137.    until e1 do e2
  138.    every e1
  139.    every e1 do e2
  140.    x
  141.    X_
  142.    &cset
  143.    &null
  144.    "abc"
  145.    'abc'
  146.    "\n"
  147.    "^a"
  148.    "\001"
  149.    "\x01"
  150.    1
  151.    999999
  152.    36ra1
  153.    3.5
  154.    2.5e4
  155.    4e-10
  156. end
  157.