@@ -103,7 +103,7 @@ void init_builtin(void)
103103 defbuiltin ("heapd" , b_heapdump , 2 );
104104 defbuiltin ("ifthen" , b_ifthen , 2 );
105105 defbuiltin ("ifthenelse" , b_ifthenelse , 3 );
106- defbuiltin ("case" , b_case , 1 );
106+ defbuiltin ("case" , b_case , 1 );
107107 defbuiltin ("inc" , b_inc , 2 );
108108 defbuiltin ("instance" , b_instance , 2 );
109109 defbuiltin ("integer" , b_integer , 1 );
@@ -322,8 +322,8 @@ void init_builtin(void)
322322 defbuiltin ("n_generate_variable" , b_n_generate_variable , 2 );
323323 defbuiltin ("n_clause_with_arity" , b_n_clause_with_arity , 3 );
324324 defbuiltin ("n_property" , b_n_property , 2 );
325- defbuiltin ("n_imported_predicate" , b_n_imported_predicate , 1 );
326- defbuiltin ("n_imported_userop" , b_n_imported_userop , 1 );
325+ defbuiltin ("n_imported_predicate" , b_n_imported_predicate , 1 );
326+ defbuiltin ("n_imported_userop" , b_n_imported_userop , 1 );
327327 defbuiltin ("n_bignum" , b_n_bignum , 1 );
328328 defbuiltin ("n_longnum" , b_n_longnum , 1 );
329329 defbuiltin ("n_findatom" , b_n_findatom , 3 );
@@ -341,9 +341,9 @@ void init_builtin(void)
341341 defbuiltin ("n_exec_greater" , b_n_exec_greater , 2 );
342342 defbuiltin ("n_exec_eqsmaller" , b_n_exec_eqsmaller , 2 );
343343 defbuiltin ("n_exec_eqgreater" , b_n_exec_eqgreater , 2 );
344- defbuiltin ("n_exec_no_operation" ,b_n_exec_no_operation , 0 );
345- defbuiltin ("n_exec_ifthen" ,b_n_exec_ifthen , 2 );
346- defbuiltin ("n_exec_ifthenelse" ,b_n_exec_ifthenelse , 3 );
344+ defbuiltin ("n_exec_no_operation" , b_n_exec_no_operation , 0 );
345+ defbuiltin ("n_exec_ifthen" , b_n_exec_ifthen , 2 );
346+ defbuiltin ("n_exec_ifthenelse" , b_n_exec_ifthenelse , 3 );
347347
348348
349349 builtins = reverse (builtins );
@@ -360,40 +360,41 @@ int exec_all(int goals, int bindings, int th)
360360 if (IS_NIL (goals ))
361361 return (YES );
362362 // ((D1;D2),Xs)
363- else if (structurep (goals ) && car (goals ) == AND && structurep (cadr (goals )) && car (cadr (goals )) == OR ) {
363+ else if (structurep (goals ) && car (goals ) == AND
364+ && structurep (cadr (goals )) && car (cadr (goals )) == OR ) {
364365 if (exec_all (cadr (cadr (goals )), bindings , th ) == YES )
365366 if (exec_all (caddr (goals ), sp [th ], th ) == YES )
366- return (YES );
367- unbind (bindings ,th );
367+ return (YES );
368+ unbind (bindings , th );
368369 if (exec_all (caddr (cadr (goals )), bindings , th ) == YES )
369370 if (exec_all (caddr (goals ), sp [th ], th ) == YES )
370- return (YES );
371- unbind (bindings ,th );
371+ return (YES );
372+ unbind (bindings , th );
372373 return (NO );
373374 }
374- // (D1,D2)
375- else if (structurep (goals ) && car (goals ) == OR ){
376- if (exec_all (cadr (goals ), bindings , th ) == YES )
377- return (YES );
378- unbind (bindings ,th );
375+ // (D1,D2)
376+ else if (structurep (goals ) && car (goals ) == OR ) {
377+ if (exec_all (cadr (goals ), bindings , th ) == YES )
378+ return (YES );
379+ unbind (bindings , th );
379380 if (exec_all (caddr (goals ), bindings , th ) == YES )
380- return (YES );
381- unbind (bindings ,th );
381+ return (YES );
382+ unbind (bindings , th );
382383 return (NO );
383- }
384+ }
384385 // ((D1,D2),Xs)
385386 else if (structurep (goals ) && car (goals ) == AND
386387 && car (cadr (goals )) == AND ) {
387388 if (exec_all (cadr (goals ), bindings , th ) == YES )
388389 return (exec_all (caddr (goals ), bindings , th ));
389390 else
390391 return (NO );
391- }
392- // predicate P
393- else if ((structurep (goals ) && car (goals ) != AND ) || atomp (goals ))
392+ }
393+ // predicate P
394+ else if ((structurep (goals ) && car (goals ) != AND ) || atomp (goals ))
394395 return (exec (goals , bindings , NIL , th ));
395396 // (P1,P2,...)
396- else {
397+ else {
397398 return (exec (cadr (goals ), bindings , caddr (goals ), th ));
398399 }
399400
@@ -1850,8 +1851,9 @@ int b_reconsult(int arglist, int rest, int th)
18501851 && length (clause ) == 2 ) {
18511852 clause = cadr (clause );
18521853 prove_all (clause , sp [th ], th );
1853- if (compiler_flag && builtinp (clause ) && compoundp (clause ) && car (clause ) == makesys ("initialization" ))
1854- goto skip ;
1854+ if (compiler_flag && builtinp (clause ) && compoundp (clause )
1855+ && car (clause ) == makesys ("initialization" ))
1856+ goto skip ;
18551857
18561858 if (!module_flag && car (clause ) != makesys ("op" ))
18571859 execute_list = cons (clause , execute_list );
@@ -2405,7 +2407,7 @@ int b_n_equalp(int arglist, int rest, int th)
24052407 if (anonymousp (arg1 ) || anonymousp (arg2 ))
24062408 return (YES );
24072409 else if (variablep (arg1 ) || variablep (arg2 ))
2408- return (YES );
2410+ return (YES );
24092411 else if (equalp (arg1 , arg2 ))
24102412 return (prove_all (rest , sp [th ], th ));
24112413 else
@@ -3953,7 +3955,7 @@ int b_ifthenelse(int arglist, int rest, int th)
39533955 return (prove_all (addtail_body (rest , arg2 , th ), sp [th ], th ));
39543956 } else {
39553957 unbind (save1 , th );
3956- return (prove_all (addtail_body (rest , arg3 , th ), sp [th ], th ));
3958+ return (prove_all (addtail_body (rest , arg3 , th ), sp [th ], th ));
39573959 }
39583960 }
39593961 exception (ARITY_ERR , ind , arglist , th );
@@ -3963,18 +3965,18 @@ int b_ifthenelse(int arglist, int rest, int th)
39633965int case_list_p (int x )
39643966{
39653967
3966- int elt ;
3967- if (predicatep (x ) || builtinp (x ) || compiledp (x ) || conjunctionp (x ))
3968- return (1 );
3969- else if (nullp (x ))
3970- return (0 );
3971- else {
3972- elt = car (x );
3973- if (!(predicatep (elt ) && car (elt ) == IFTHEN ))
3974- return (case_list_p (cdr (x )));
3975- else
3976- return 0 ;
3977- }
3968+ int elt ;
3969+ if (predicatep (x ) || builtinp (x ) || compiledp (x ) || conjunctionp (x ))
3970+ return (1 );
3971+ else if (nullp (x ))
3972+ return (0 );
3973+ else {
3974+ elt = car (x );
3975+ if (!(predicatep (elt ) && car (elt ) == IFTHEN ))
3976+ return (case_list_p (cdr (x )));
3977+ else
3978+ return 0 ;
3979+ }
39783980}
39793981
39803982int b_case (int arglist , int rest , int th )
@@ -3990,14 +3992,18 @@ int b_case(int arglist, int rest, int th)
39903992 if (!(listp (arg1 ) && case_list_p (arg1 )))
39913993 exception (ILLEGAL_ARGS , ind , arg1 , th );
39923994
3993- while (!(predicatep (arg1 ) || builtinp (arg1 ) || compiledp (arg1 ) || conjunctionp (arg1 ))){
3994- ifthen = car (arg1 );
3995- if (prove_all (cadr (ifthen ), sp [th ], th ) == YES )
3996- return (prove_all (addtail_body (rest , caddr (ifthen ), th ), sp [th ], th ));
3997- arg1 = cdr (arg1 );
3998- unbind (save1 , th );
3995+ while (!
3996+ (predicatep (arg1 ) || builtinp (arg1 ) || compiledp (arg1 )
3997+ || conjunctionp (arg1 ))) {
3998+ ifthen = car (arg1 );
3999+ if (prove_all (cadr (ifthen ), sp [th ], th ) == YES )
4000+ return (prove_all
4001+ (addtail_body (rest , caddr (ifthen ), th ), sp [th ],
4002+ th ));
4003+ arg1 = cdr (arg1 );
4004+ unbind (save1 , th );
39994005 }
4000-
4006+
40014007 return (prove_all (addtail_body (rest , arg1 , th ), sp [th ], th ));
40024008
40034009 }
0 commit comments