Changeset 4600 for trunk/examples

Show
Ignore:
Timestamp:
11/21/08 15:34:32 (7 weeks ago)
Author:
pmoura
Message:

Updated the "expansion" example to illustrate the new expand_goal/2 built-in method.

Location:
trunk/examples/expansion
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/expansion/expansion.lgt

    r3936 r4600  
    1414    term_expansion(9, nine). 
    1515 
     16    goal_expansion(write(Term), writeq(Term)). 
     17    goal_expansion(writeq(Term), write_term(Term, [quoted(true)])). 
     18 
    1619:- end_category. 
    1720 
     
    1922:- category(conversion_test). 
    2023 
    21     :- public(test/2). 
     24    :- public(test_term/2). 
    2225 
    23     test(Term, Expansion) :- 
     26    test_term(Term, Expansion) :- 
    2427        expand_term(Term, Expansion). 
     28 
     29    :- public(test_goal/2). 
     30 
     31    test_goal(Goal, EGoal) :- 
     32        expand_goal(Goal, EGoal). 
    2533 
    2634:- end_category. 
  • trunk/examples/expansion/SCRIPT.txt

    r4572 r4600  
    1616 
    1717 
    18 % simple tests of the expand_term/2 built-in method: 
     18% simple tests of the expand_term/2 and expand_goal/2 built-in methods: 
    1919 
    2020| ?- exp_public::expand_term(8, Term). 
     
    2323yes 
    2424 
     25| ?- exp_public::expand_goal(write(Term), EGoal). 
     26 
     27EGoal = write_term(Term, [quoted(true)]). 
     28yes 
     29 
     30 
    2531| ?- exp_protected::expand_term(8, Term). 
    2632 
    2733Term = 8  
    2834yes 
     35 
     36| ?- exp_protected::expand_goal(write(Term), EGoal). 
     37 
     38EGoal = write(Term). 
     39yes 
     40 
    2941 
    3042| ?- exp_private::expand_term(8, Term). 
     
    3345yes 
    3446 
    35 | ?- desc_public::test(8, Term). 
     47| ?- exp_private::expand_goal(write(Term), EGoal). 
     48 
     49EGoal = write(Term). 
     50yes 
     51 
     52 
     53| ?- desc_public::test_term(8, Term). 
    3654 
    3755Term = eight  
    3856yes 
    3957 
    40 | ?- desc_protected::test(8, Term). 
     58| ?- desc_public::test_goal(write(Term), EGoal). 
     59 
     60EGoal = write_term(Term, [quoted(true)]) 
     61yes 
     62 
     63 
     64| ?- desc_protected::test_term(8, Term). 
    4165 
    4266Term = eight  
    4367yes 
    4468 
    45 | ?- desc_private::test(8, Term). 
     69| ?- desc_protected::test_goal(write(Term), EGoal). 
     70 
     71EGoal = write_term(Term, [quoted(true)]) 
     72yes 
     73 
     74 
     75| ?- desc_private::test_term(8, Term). 
    4676 
    4777Term = 8  
    4878yes 
     79 
     80| ?- desc_private::test_goal(write(Term), EGoal). 
     81 
     82EGoal = write(Term) 
     83yes