Check-in [a992c2ca2e]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed a bug in fill that was duplicating _'s in the to-be-copied term.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a992c2ca2e786b2a5e71dcb199374a355dbd961f
User & Date: andy 2015-04-16 21:59:59
Context
2015-04-16
22:00
Fixed a bug in merging of substitutions with some arguments unbound. check-in: acfcbdeb7a user: andy tags: trunk
21:59
Fixed a bug in fill that was duplicating _'s in the to-be-copied term. check-in: a992c2ca2e user: andy tags: trunk
21:59
Fixed a few bugs in rendering of proofs (commas between antecedants, tabindexes on conclusions so they can be keyboard-focused). check-in: 5ae5431e8f user: andy tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to plsrc/util.pl.

13
14
15
16
17
18
19
20




21
22
23

24
25
replace_nth0([_|Rest],0,Elem,[Elem|Rest]).
replace_nth0([I|Is],N,Elem,[I|Rest]) :-
    N > 0,
    N2 is N - 1,
    replace_nth0(Is,N2,Elem,Rest).

% fill(List,Elem,N)
% Fill List with N copies of Elem.




fill([],_,0).
fill([Elem|Es],Elem,N) :-
    N > 0,

    N2 is N - 1,
    fill(Es,Elem,N2).







|
>
>
>
>

|

>


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
replace_nth0([_|Rest],0,Elem,[Elem|Rest]).
replace_nth0([I|Is],N,Elem,[I|Rest]) :-
    N > 0,
    N2 is N - 1,
    replace_nth0(Is,N2,Elem,Rest).

% fill(List,Elem,N)
% Fill List with N *copies* of Elem. Note that we have to use copy_term here,
% otherwise you run into trouble with _s. E.g., without copy copy_term
%   fill(List,_,2) ==> List = [_G01,_G01]
% I.e., both anonymous variables end up being the *same*, so the list will
% only unify with identical pairs.
fill([],_,0).
fill([Copy|Es],Elem,N) :-
    N > 0,
    copy_term(Elem,Copy),
    N2 is N - 1,
    fill(Es,Elem,N2).