Visual Prolog searches the clauses for matching call in the order of their appearance in the code, so if first argument is zero, it starts with first clause factorial(0,F). There are two possible matches for each call of factorial - with zero or arbitrary first argument. In main.pro the actual description of newly specified predicate takes place. Keyword procedure describes the behavior of predicate, indicating that is will always succeed with only one solution, so no backtracking is required. specifies that factorial is a predicate of arity 2, with known first and unknown second argument. In main.cl the only added line factorial : (integer N, integer F) procedure (i,o). Create a new project with UI Strategy “Console” and replace contents of files main.cl and main.pro with given code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |