home *** CD-ROM | disk | FTP | other *** search
-
- STEP 1
- |----------|ì
- alloc_str ----> ⁿ constant ⁿì
- |----------|ì
- | c |ì
- |----------|ì
- ì
- alloc_str(constant,'c')
-
- STEP 2
- ì
- |----------|ì
- ⁿ cons ⁿ tail_ptrì
- |----------| ì
- cons ---------> | ---------> NILì
- |----------|ì
- | |ì
- |----------|ì
- | head_ptr
- Vì
- |----------|ì
- ⁿ constant ⁿì
- |----------|ì
- | c |ì
- |----------|ì
- ì
- cons(alloc_str(constant,'c'),NIL)
-
-
- STEP 3 ì
- ì
- ì
- |----------| |----------| |----------|ì
- ⁿ cons ⁿ ⁿ cons ⁿ ⁿ cons ⁿì
- |----------| |----------| |----------|ì
- list ---------> | --------->| --------->| ------> NILì
- |----------| |----------| |----------|ì
- | | | | | |ì
- |----|-----| |----|-----| |----|-----|ì
- | | |
- V V V ì
- |----------| |----------| |----------|ì
- ⁿ constant ⁿ ⁿ constant ⁿ ⁿ constant ⁿì
- |----------| |----------| |----------|ì
- | a | | b | | c |ì
- |----------| |----------| |----------|ì
- ì
-
- list := cons(alloc_str(constant,'a'),cons(alloc_str(constant,'b'),
- cons(alloc_str(constant,'c'),NIL)))
-
- Figure 5 - Constructing the list ('a','b','c') .