File: action.li

package info (click to toggle)
lisaac 1%3A0.13.1-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,232 kB
  • ctags: 6,386
  • sloc: ansic: 242,479; xml: 635; lisp: 333; makefile: 119; sh: 73; asm: 38
file content (72 lines) | stat: -rw-r--r-- 2,620 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
///////////////////////////////////////////////////////////////////////////////
//                              Lisaac Example                               //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header
  
  + name := ACTION;
  
Section Public
  
  - main <-
  ( + col1:FAST_ARRAY[INTEGER];
    + col2:LINKED_LIST[INTEGER];
    + action1:BLOCK;
    //+ action2:BLOCK;
    + somme:INTEGER;
    
    // Creation d'un tableau de 5 elements de 0  4 :
    col1 := FAST_ARRAY[INTEGER].create_with_capacity 5;
    // Cration d'une liste chainee:
    col2 := LINKED_LIST[INTEGER].create;
    
    // Rempli la premire collection.
    1.to 10 do { j:INTEGER;
      col1.add_last j;
      col2.add_last (j+j);
    };
    
    // QUESTION 1
                
    // Action d'afficher un lment:
    action1 := {       
      i:INTEGER;  // argument
      
      i.print;
      ','.print;
    };
    
    // Affichage de `col1' et `col2' avec `action1':
    col1.foreach action1;
    col2.foreach action1;
    
    // POINT 2
    
    // QUESTION 3    
    
    //action2 := { 
    // ... A vous de jouer ...
    //};
    
    // col2.foreach action2;
    
    "Somme : ".print;
    somme.print;
    '\n'.print;
  );