Version
8
Directory list with the 6 programs
Code:
DIR
L.SWAP
\<< "3/2 Arg: List & a/b
a) \|>Pos.i \|>Pos.k
b) or \|>{Pos.i Pos.k}
(as a list)
" DROP 0 \-> p1 p2 L
\<< p2 TYPE 5 == p2 SIZE 2 == AND
IF
THEN p1 p2 OBJ\-> DROP
ELSE p1 p2
END 3 \->LIST { L p1 p2 } STO L p1 GET L p2 GET L p1 ROT PUT p2 ROT PUT
\>>
\>>
L.DEL
\<< "3/2 Arg: List & a/b/c
a)\|>Pos.beg \|>Pos.end
(from Posbeg \-> Posend)
b)or \|>{Pos.i Pos.k }
(as a list)
c)or just Pos or {Pos}
" DROP
IFERR \<-keep
THEN 0
END \-> L l \<-keep
\<<
CASE L TYPE 5 == l TYPE 5 \=/ AND
THEN l 1 \->LIST 'l' STO
END L TYPE 5 \=/ l TYPE 5 \=/ AND
THEN { } L l MIN L l MAX
FOR i i +
NEXT 'l' STO 'L' STO
END
END l 1. * 'l' STO { } 1 L SIZE
FOR i l i POS 0 \<-keep 1 ==
IF
THEN \=/
ELSE ==
END
IF
THEN L i GET DUP TYPE 5 == { 1 \->LIST } IFT +
END
NEXT
\>>
\>>
L.KEEP
\<< "3/2 Arg: List & a/b/c
a)\|>Pos.beg \|>Pos.end
(from Posbeg \-> Posend)
b)or \|>{Pos.i Pos.k }
(as a list)
c)or just Pos or {Pos}
" DROP 1 \-> \<-keep
\<< L.DEL
\>>
\>>
L.ADD
\<< "3 Arg:
\|>List
\|>PosStart (not after)
\|>{El.1 El.2 }
or just Elem
" DROP 0 \-> L p l S
\<<
IF l TYPE 5 \=/ l TYPE 5 == l SIZE 1 \<= AND OR
THEN l 1 \->LIST 'l' STO
END L SIZE 'S' STO
CASE p S >
THEN L l +
END p 1 ==
THEN l L +
END { } 1 p 1 -
FOR i L i GET DUP TYPE 5 == { 1 \->LIST } IFT +
NEXT { } p S
FOR i L i GET DUP TYPE 5 == { 1 \->LIST } IFT +
NEXT l SWAP + +
END
\>>
\>>
L.RPL
\<< "4/3 Arg: List & 1+2
1) What to be repl:
a) \|>Pos.beg \|>Pos.end
(from Posbeg \-> Posend)
or b) \|>{Pos.i Pos.k }
(as a list)
or c) Pos or {Pos}
And 2) New:
\|>{El.I El.K }
or just Elem or {Elem}
To delete El. in Pos.j
1) {Pos.i Pos.j Pos.k}
2) {I empty.string K}
\-> Result: { I K }
To delete a pos, d var
below can be modified;
default: empty.string
To use, you must have:
L.DEL & L.ADD !
" DROP "" \-> d
\<< OVER DUP TYPE 5 == SWAP SIZE 1 == AND
IF
THEN SWAP 1 GET SWAP
END DUP2 TYPE SWAP TYPE * 25 ==
IF
THEN DUP SIZE \-> l1 l2 s
\<< l1 HEAD 1 \->LIST 2 s
FOR i l1 l2 i 1 - GET DUP TYPE 5 ==
IF
THEN SIZE 1 - ADD DUP 'l1' STO
ELSE DROP
END i GET +
NEXT 'l1' STO 1 s
FOR i l1 i GET DUP UNROT L.DEL SWAP l2 i GET DUP dd SAME NOT
IF
THEN L.ADD
ELSE DROP2 l1 -1 ADD 'l1' STO
END
NEXT
\>>
ELSE PICK3 DUP TYPE 5 ==
IF
THEN DROP OVER 4 ROLLD 4 ROLLD
ELSE PICK3 MIN 5 ROLLD 5 ROLLD
END L.DEL SWAP ROT DUP d SAME NOT
IF
THEN L.ADD
ELSE DROP2
END
END
\>>
\>>
LeRPL
\<< "3 Arg: List & 1+2
List & occurrences
of specific elem a b
olda \-> newA
oldb \-> newB
Repl all repeated occ
1) {a b} 2) {A B}
or 1) a 2) A
Repl # limited occurr
1){\oo# a b} 2) {A B}
or 1) {\oo# a} 2) A
#:#MaxReplac for a/b
# preceded by \oo sign
If b\->B c\->deleted d\->D
{b c d ) 1){b c d}
2) {B empty.string D}
\-> Result: { B D }
To delete Elem, var d
below can be modified;
default: empty.string
To use, you must have
L.DEL & L.ADD !
" DROP 0 0 0 0 0 "" \-> L l1 l2 s1 c cf p ct d
\<<
IF l1 TYPE 5 \=/ l1 TYPE 5 == l1 SIZE 1 == AND OR
THEN l1 1 \->LIST 'l1' STO 1
ELSE l1 SIZE
END 's1' STO
IF l2 TYPE 5 \=/ l2 TYPE 5 == l2 SIZE 1 \<= AND OR
THEN l2 1 \->LIST 'l2' STO
END
IF l1 HEAD DUP TYPE 6 ==
THEN \->STR 'cf' STO
IF cf 2 2 SUB "\oo" SAME
THEN l1 1 L.DEL 'l1' STO -1 's1' STO+ cf 3 cf SIZE 1 - SUB OBJ\-> L SIZE MIN
ELSE L SIZE
END
ELSE DROP L SIZE
END 'cf' STO L 1 s1
FOR i 0
WHILE cf <
REPEAT DUP l1 i GET POS DUP 'p' STO 0 \=/
IF
THEN 1 'c' STO+ 1 'ct' STO+ p L.DEL p l2 i GET DUP "" SAME NOT
IF
THEN L.ADD
ELSE DROP2
END c
ELSE cf
END
END 0 'c' STO
NEXT ct "Changes" \->TAG
\>>
\>>
END