Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -15,37 +15,37 @@
|
|||
;------------------------------------------------------
|
||||
; Constant Section
|
||||
;
|
||||
StrPtr = $6 0-page temp pointer (2 bytes)
|
||||
Low = $8 0-page temp low bound
|
||||
High = $9 0-page temp high bound
|
||||
CharOut = $fded Specific to the Apple II
|
||||
BigA = "A" 'A' for normal ascii
|
||||
BigZ = "Z" 'Z' " " "
|
||||
LittleA = "a" 'a' " " "
|
||||
LittleZ = "z" 'z' " " "
|
||||
StrPtr = $6 ;0-page temp pointer (2 bytes)
|
||||
Low = $8 ;0-page temp low bound
|
||||
High = $9 ;0-page temp high bound
|
||||
CharOut = $fded ;Specific to the Apple II
|
||||
BigA = "A" ;'A' for normal ascii
|
||||
BigZ = "Z" ;'Z' " " "
|
||||
LittleA = "a" ;'a' " " "
|
||||
LittleZ = "z" ;'z' " " "
|
||||
;======================================================
|
||||
.or $0f00
|
||||
;------------------------------------------------------
|
||||
; The main program
|
||||
;
|
||||
main ldx #sTest Point to the test string
|
||||
main ldx #sTest ;Point to the test string
|
||||
lda /sTest
|
||||
jsr puts print it to stdout
|
||||
jsr toUpper convert to UPPER-case
|
||||
jsr puts print it
|
||||
jsr toLower convert to lower-case
|
||||
jmp puts print it and return to caller
|
||||
jsr puts ;print it to stdout
|
||||
jsr toUpper ;convert to UPPER-case
|
||||
jsr puts ;print it
|
||||
jsr toLower ;convert to lower-case
|
||||
jmp puts ;print it and return to caller
|
||||
;------------------------------------------------------
|
||||
toUpper ldy #LittleA
|
||||
sty Low set up the flip range
|
||||
sty Low ;set up the flip range
|
||||
ldy #LittleZ
|
||||
bne toLow2 return via toLower's tail
|
||||
bne toLow2 ;return via toLower's tail
|
||||
;------------------------------------------------------
|
||||
toLower ldy #BigA
|
||||
sty Low set up the flip range
|
||||
sty Low ;set up the flip range
|
||||
ldy #BigZ
|
||||
toLow2 sty High
|
||||
; return via fall-thru to flip
|
||||
; ;return via fall-thru to flip
|
||||
;------------------------------------------------------
|
||||
; Given a NUL-terminated string at A:X, flip the case
|
||||
; of any chars in the range [Low..High], inclusive;
|
||||
|
|
@ -54,23 +54,23 @@ toLow2 sty High
|
|||
; Preserves: A, X
|
||||
; Trashes: Y
|
||||
;
|
||||
flip stx StrPtr init string pointer
|
||||
flip stx StrPtr ;init string pointer
|
||||
sta StrPtr+1
|
||||
ldy #0
|
||||
pha save A
|
||||
flip2 lda (StrPtr),y get string char
|
||||
beq flip5 done if NUL
|
||||
pha ;save A
|
||||
flip2 lda (StrPtr),y ;get string char
|
||||
beq flip5 ;done if NUL
|
||||
cmp Low
|
||||
bcc flip4 if Low <= char <= High
|
||||
bcc flip4 ;if Low <= char <= High
|
||||
cmp High
|
||||
beq flip3
|
||||
bcs flip4
|
||||
flip3 eor #$20 then flip the case
|
||||
flip3 eor #$20 ; then flip the case
|
||||
sta (StrPtr),y
|
||||
flip4 iny point to next char
|
||||
bne flip2 loop up to 255 times
|
||||
flip5 pla restore A
|
||||
rts return
|
||||
flip4 iny ;point to next char
|
||||
bne flip2 ;loop up to 255 times
|
||||
flip5 pla ;restore A
|
||||
rts ;return
|
||||
;------------------------------------------------------
|
||||
; Output NUL-terminated string @ A:X; strings longer
|
||||
; than 256 bytes are truncated there
|
||||
|
|
@ -78,17 +78,17 @@ flip5 pla restore A
|
|||
; Preserves: A, X
|
||||
; Trashes: Y
|
||||
;
|
||||
puts stx StrPtr init string pointer
|
||||
puts stx StrPtr ;init string pointer
|
||||
sta StrPtr+1
|
||||
ldy #0
|
||||
pha save A
|
||||
puts2 lda (StrPtr),y get string char
|
||||
beq puts3 done if NUL
|
||||
jsr CharOut output the char
|
||||
iny point to next char
|
||||
bne puts2 loop up to 255 times
|
||||
puts3 pla restore A
|
||||
rts return
|
||||
pha ;save A
|
||||
puts2 lda (StrPtr),y ;get string char
|
||||
beq puts3 ;done if NUL
|
||||
jsr CharOut ;output the char
|
||||
iny ;point to next char
|
||||
bne puts2 ;loop up to 255 times
|
||||
puts3 pla ;restore A
|
||||
rts ;return
|
||||
;------------------------------------------------------
|
||||
; Test String (in '+128' ascii, Apple II style)
|
||||
;
|
||||
|
|
|
|||
5
Task/String-case/BASIC/string-case-2.basic
Normal file
5
Task/String-case/BASIC/string-case-2.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
S$ = "alphaBETA"
|
||||
|
||||
UP$ = "" : FOR I = 1 TO LEN(S$) : C = ASC(MID$(S$, I, 1)) : UP$ = UP$ + CHR$(C - (C > 96 AND C < 123) * 32) : NEXT I : ? UP$
|
||||
|
||||
LO$ = "" : FOR I = 1 TO LEN(S$) : C = ASC(MID$(S$, I, 1)) : LO$ = LO$ + CHR$(C + (C > 64 AND C < 91) * 32) : NEXT I : ? LO$
|
||||
7
Task/String-case/BASIC/string-case-3.basic
Normal file
7
Task/String-case/BASIC/string-case-3.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
INSTALL @lib$+"STRINGLIB"
|
||||
|
||||
original$ = "alphaBETA"
|
||||
PRINT "Original: " original$
|
||||
PRINT "Lower case: " FN_lower(original$)
|
||||
PRINT "Upper case: " FN_upper(original$)
|
||||
PRINT "Title case: " FN_title(original$)
|
||||
7
Task/String-case/BASIC/string-case-4.basic
Normal file
7
Task/String-case/BASIC/string-case-4.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
input$ ="alphaBETA"
|
||||
|
||||
print input$
|
||||
print upper$( input$)
|
||||
print lower$( input$)
|
||||
|
||||
end
|
||||
5
Task/String-case/BASIC/string-case-5.basic
Normal file
5
Task/String-case/BASIC/string-case-5.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
string s="alphaBETA"
|
||||
|
||||
print lcase(s) " "+
|
||||
ucase(s) " "+
|
||||
ucase(left(s,1))+mid(s,2) 'capitalised
|
||||
3
Task/String-case/BASIC/string-case-6.basic
Normal file
3
Task/String-case/BASIC/string-case-6.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s$ = "alphaBETA"
|
||||
upper$ = UCase(s$) ;uppercase
|
||||
lower$ = LCase(s$) ;lowercase
|
||||
5
Task/String-case/BASIC/string-case-7.basic
Normal file
5
Task/String-case/BASIC/string-case-7.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a$ ="alphaBETA"
|
||||
|
||||
print a$ '=> alphaBETA
|
||||
print upper$(a$) '=> ALPHABETA
|
||||
print lower$(a$) '=> alphabeta
|
||||
8
Task/String-case/BASIC/string-case-8.basic
Normal file
8
Task/String-case/BASIC/string-case-8.basic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
' Define 's'
|
||||
Dim s AS String = "alphaBETA"
|
||||
|
||||
' Change 's' to Upper Case.
|
||||
s = s.ToUpper()
|
||||
|
||||
' Change 's' to Lower Case.
|
||||
s = s.ToLower()
|
||||
18
Task/String-case/BASIC/string-case-9.basic
Normal file
18
Task/String-case/BASIC/string-case-9.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"→Str9
|
||||
:"abcdefghijklmnopqrstuvwxyz"→Str0
|
||||
:Input ">",Str1
|
||||
:":"+Str1+":"→Str1
|
||||
:Prompt U
|
||||
:If U:Then
|
||||
:For(I,2,length(Str1))
|
||||
:If inString(Str0,sub(Str1,I,1)) and sub(Str1,I,1)≠":"
|
||||
:sub(Str1,1,I-1)+sub(Str9,inString(Str0,sub(Str1,I,1)),1)+sub(Str1,I+1,length(Str1)-I)→Str1
|
||||
:End
|
||||
:Else
|
||||
:For(I,2,length(Str1))
|
||||
:If inString(Str9,sub(Str1,I,1)) and sub(Str1,I,1)≠":"
|
||||
:sub(Str1,1,I-1)+sub(Str0,inString(Str9,sub(Str1,I,1)),1)+sub(Str1,I+1,length(Str1)-I)→Str1
|
||||
:End
|
||||
:End
|
||||
:sub(Str1,2,length(Str1)-2)→Str1
|
||||
:Pause Str1
|
||||
2
Task/String-case/GAP/string-case.gap
Normal file
2
Task/String-case/GAP/string-case.gap
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
LowercaseString("alphaBETA");
|
||||
UppercaseString("alphaBETA");
|
||||
|
|
@ -10,16 +10,19 @@ import (
|
|||
func main() {
|
||||
show("alphaBETA")
|
||||
show("alpha BETA")
|
||||
show("DŽLjnj") // should render similar to DZLjnj
|
||||
// Three digraphs that should render similar to DZ, Lj, and nj.
|
||||
show("DŽLjnj")
|
||||
// Unicode apostrophe in third word.
|
||||
show("o'hare O'HARE o’hare don't")
|
||||
}
|
||||
|
||||
func show(s string) {
|
||||
fmt.Println("\nstring: ", s, "len:", utf8.RuneCountInString(s))
|
||||
fmt.Println("\nstring: ",
|
||||
s, " len:", utf8.RuneCountInString(s), "runes") // DZLjnj
|
||||
fmt.Println("All upper case: ", strings.ToUpper(s)) // DZLJNJ
|
||||
fmt.Println("All lower case: ", strings.ToLower(s)) // dzljnj
|
||||
fmt.Println("All title case: ", strings.ToTitle(s)) // DzLjNj
|
||||
// notice Title() only modifies first letters of words
|
||||
// non-first letters keep their case.
|
||||
fmt.Println("Title words: ", strings.Title(s)) // Dzljnj
|
||||
fmt.Println("Swapping case: ", strings.Map(unicode.SimpleFold, s))
|
||||
fmt.Println("Title words: ", strings.Title(s)) // Dzljnj
|
||||
fmt.Println("Swapping case: ", // DzLjNJ
|
||||
strings.Map(unicode.SimpleFold, s))
|
||||
}
|
||||
|
|
|
|||
5
Task/String-case/Julia/string-case.julia
Normal file
5
Task/String-case/Julia/string-case.julia
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
julia> uppercase("alphaBETA")
|
||||
"ALPHABETA"
|
||||
|
||||
julia> lowercase("alphaBETA")
|
||||
"alphabeta"
|
||||
7
Task/String-case/VBA/string-case.vba
Normal file
7
Task/String-case/VBA/string-case.vba
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Function StringCase()
|
||||
Dim s As String
|
||||
s = "alphaBETA"
|
||||
Debug.Print UCase(s)
|
||||
Debug.Print LCase(s)
|
||||
Debug.Print WorksheetFunction.Proper(s)
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue