fix foreach
This commit is contained in:
parent
9b6bcdde16
commit
5b19e9546a
@ -26,7 +26,7 @@ arrays. these arrays are allocated in the stack, and disppear in
|
||||
backtracking. Matrices are available by loading the library
|
||||
`library(matrix)`. They are multimensional objects of type:
|
||||
|
||||
+ <tt>terms</tt>: Prolog terms
|
||||
+ <tt>terms</tt>: Prolog terms
|
||||
|
||||
+ <tt>ints</tt>: bounded integers, represented as an opaque term. The
|
||||
maximum integer depends on hardware, but should be obtained from the
|
||||
@ -39,7 +39,7 @@ predicate or through an <tt>R</tt>-inspired access notation (that uses the ciao
|
||||
style extension to `[]`). Examples include:
|
||||
|
||||
|
||||
+ Access the second row, third column of matrix <tt>X</tt>. Indices start from
|
||||
+ Access the second row, third column of matrix <tt>X</tt>. Indices start from
|
||||
`0`,
|
||||
~~~~
|
||||
_E_ <== _X_[2,3]
|
||||
@ -809,23 +809,23 @@ index(I..J, _M, [I|O] ) :- !,
|
||||
index(I:J, _M, [I|O] ) :- !,
|
||||
I1 is I, J1 is J,
|
||||
once( foldl(inc, O, I1, J1) ).
|
||||
index(I+J, _M, O ) :- !,
|
||||
index(I+J, M, O ) :- !,
|
||||
index(I, M, I1),
|
||||
index(J, M, J1),
|
||||
add_index(I1, J1, O).
|
||||
index(I-J, _M, O ) :- !,
|
||||
index(I-J, M, O ) :- !,
|
||||
index(I, M, I1),
|
||||
index(J, M, J1),
|
||||
sub_index(I1, J1, O).
|
||||
index(I*J, _M, O ) :- !,
|
||||
index(I*J, M, O ) :- !,
|
||||
index(I, M, I1),
|
||||
index(J, M, J1),
|
||||
O is I1*J1.
|
||||
index(I div J, _M, O ) :- !,
|
||||
index(I div J, M, O ) :- !,
|
||||
index(I, M, I1),
|
||||
index(J, M, J1),
|
||||
O is I1 div J1.
|
||||
index(I rem J, _M, O ) :- !,
|
||||
index(I rem J, M, O ) :- !,
|
||||
index(I, M, I1),
|
||||
index(J, M, J1),
|
||||
O is I1 rem J1.
|
||||
@ -1387,4 +1387,3 @@ ints(A,B,O) :-
|
||||
( A > B -> O = [] ; O = [A|L], A1 is A+1, ints(A1,B,L) ).
|
||||
|
||||
zero(_, 0).
|
||||
|
||||
|
Reference in New Issue
Block a user