June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,5 +1,3 @@
|
|||
string s="alphaBETA"
|
||||
|
||||
print lcase(s) " "+
|
||||
ucase(s) " "+
|
||||
ucase(left(s,1))+mid(s,2) 'capitalised
|
||||
s$ = "alphaBETA"
|
||||
upper$ = UCase(s$) ;uppercase
|
||||
lower$ = LCase(s$) ;lowercase
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
s$ = "alphaBETA"
|
||||
upper$ = UCase(s$) ;uppercase
|
||||
lower$ = LCase(s$) ;lowercase
|
||||
a$ ="alphaBETA"
|
||||
|
||||
print a$ '=> alphaBETA
|
||||
print upper$(a$) '=> ALPHABETA
|
||||
print lower$(a$) '=> alphabeta
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
a$ ="alphaBETA"
|
||||
' Define 's'
|
||||
Dim s AS String = "alphaBETA"
|
||||
|
||||
print a$ '=> alphaBETA
|
||||
print upper$(a$) '=> ALPHABETA
|
||||
print lower$(a$) '=> alphabeta
|
||||
' Change 's' to Upper Case.
|
||||
s = s.ToUpper()
|
||||
|
||||
' Change 's' to Lower Case.
|
||||
s = s.ToLower()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
' Define 's'
|
||||
Dim s AS String = "alphaBETA"
|
||||
|
||||
' Change 's' to Upper Case.
|
||||
s = s.ToUpper()
|
||||
|
||||
' Change 's' to Lower Case.
|
||||
s = s.ToLower()
|
||||
:"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
|
||||
|
|
|
|||
76
Task/String-case/Fortran/string-case-4.f
Normal file
76
Task/String-case/Fortran/string-case-4.f
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
module uplow
|
||||
implicit none
|
||||
character(len=26), parameter, private :: low = "abcdefghijklmnopqrstuvwxyz"
|
||||
character(len=26), parameter, private :: high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
contains
|
||||
|
||||
function to_upper(s) result(t)
|
||||
! returns upper case of s
|
||||
implicit none
|
||||
character(len=*), intent(in) :: s
|
||||
character(len=len(s)) :: t
|
||||
|
||||
character(len=1), save :: convtable(0:255)
|
||||
logical, save :: first = .true.
|
||||
integer :: i
|
||||
|
||||
if(first) then
|
||||
do i=0,255
|
||||
convtable(i) = char(i)
|
||||
enddo
|
||||
do i=1,len(low)
|
||||
convtable(iachar(low(i:i))) = char(iachar(high(i:i)))
|
||||
enddo
|
||||
first = .false.
|
||||
endif
|
||||
|
||||
t = s
|
||||
|
||||
do i=1,len_trim(s)
|
||||
t(i:i) = convtable(iachar(s(i:i)))
|
||||
enddo
|
||||
|
||||
end function to_upper
|
||||
|
||||
function to_lower(s) result(t)
|
||||
! returns lower case of s
|
||||
implicit none
|
||||
character(len=*), intent(in) :: s
|
||||
character(len=len(s)) :: t
|
||||
|
||||
character(len=1), save :: convtable(0:255)
|
||||
logical, save :: first = .true.
|
||||
integer :: i
|
||||
|
||||
if(first) then
|
||||
do i=0,255
|
||||
convtable(i) = char(i)
|
||||
enddo
|
||||
do i = 1,len(low)
|
||||
convtable(iachar(high(i:i))) = char(iachar(low(i:i)))
|
||||
enddo
|
||||
first = .false.
|
||||
endif
|
||||
|
||||
t = s
|
||||
|
||||
do i=1,len_trim(s)
|
||||
t(i:i) = convtable(iachar(s(i:i)))
|
||||
enddo
|
||||
|
||||
end function to_lower
|
||||
|
||||
|
||||
end module uplow
|
||||
|
||||
|
||||
program doit
|
||||
use uplow
|
||||
character(len=40) :: s
|
||||
|
||||
s = "abcdxyz ZXYDCBA _!@"
|
||||
print *,"original: ",'[',s,']'
|
||||
print *,"to_upper: ",'[',to_upper(s),']'
|
||||
print *,"to_lower: ",'[',to_lower(s),']'
|
||||
|
||||
end program doit
|
||||
7
Task/String-case/Red/string-case.red
Normal file
7
Task/String-case/Red/string-case.red
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
str: "alphaBETA"
|
||||
>> uppercase str
|
||||
== "ALPHABETA"
|
||||
>> lowercase str
|
||||
== "alphabeta"
|
||||
>> uppercase/part str 5
|
||||
== "ALPHAbeta"
|
||||
6
Task/String-case/Simula/string-case.simula
Normal file
6
Task/String-case/Simula/string-case.simula
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
TEXT soup, lower;
|
||||
soup :- "alphaBETA";
|
||||
lower :- LOWCASE(COPY(soup)); ! COPY, else soup is changed;
|
||||
OutText("upper: "); OutText(UPCASE("alphaBETA"));
|
||||
OutText(", lower: "); OutText(lower);
|
||||
OutText(", soup: "); OutText(soup); Outimage;
|
||||
Loading…
Add table
Add a link
Reference in a new issue