September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,54 +1,52 @@
|
|||
use framework "Foundation"
|
||||
|
||||
-- toUpperCase :: Text -> Text
|
||||
on toUpperCase(str)
|
||||
set ca to current application
|
||||
((ca's NSString's stringWithString:(str))'s ¬
|
||||
uppercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
|
||||
end toUpperCase
|
||||
|
||||
-- toLowerCase :: Text -> Text
|
||||
on toLowerCase(str)
|
||||
set ca to current application
|
||||
((ca's NSString's stringWithString:(str))'s ¬
|
||||
lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
|
||||
end toLowerCase
|
||||
|
||||
-- toCapitalized :: Text -> Text
|
||||
on toCapitalized(str)
|
||||
set ca to current application
|
||||
((ca's NSString's stringWithString:(str))'s ¬
|
||||
capitalizedStringWithLocale:(ca's NSLocale's currentLocale())) as text
|
||||
end toCapitalized
|
||||
|
||||
|
||||
-- TEST
|
||||
-- TEST -----------------------------------------------------------------------
|
||||
on run
|
||||
|
||||
-- testCase :: Handler -> String
|
||||
script testCase
|
||||
on lambda(f)
|
||||
mReturn(f)'s lambda("alphaBETA αβγδΕΖΗΘ")
|
||||
end lambda
|
||||
end script
|
||||
ap({toLower, toTitle, toUpper}, {"alphaBETA αβγδΕΖΗΘ"})
|
||||
|
||||
map(testCase, {toUpperCase, toLowerCase, toCapitalized})
|
||||
--> {"alphabeta αβγδεζηθ", "Alphabeta Αβγδεζηθ", "ALPHABETA ΑΒΓΔΕΖΗΘ"}
|
||||
|
||||
end run
|
||||
|
||||
|
||||
-- GENERIC FUNCTIONS
|
||||
-- map :: (a -> b) -> [a] -> [b]
|
||||
on map(f, xs)
|
||||
tell mReturn(f)
|
||||
set lng to length of xs
|
||||
set lst to {}
|
||||
repeat with i from 1 to lng
|
||||
set end of lst to lambda(item i of xs, i, xs)
|
||||
end repeat
|
||||
return lst
|
||||
end tell
|
||||
end map
|
||||
-- GENERIC FUNCTIONS ----------------------------------------------------------
|
||||
|
||||
-- toLower :: String -> String
|
||||
on toLower(str)
|
||||
set ca to current application
|
||||
((ca's NSString's stringWithString:(str))'s ¬
|
||||
lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
|
||||
end toLower
|
||||
|
||||
-- toTitle :: String -> String
|
||||
on toTitle(str)
|
||||
set ca to current application
|
||||
((ca's NSString's stringWithString:(str))'s ¬
|
||||
capitalizedStringWithLocale:(ca's NSLocale's currentLocale())) as text
|
||||
end toTitle
|
||||
|
||||
-- toUpper :: String -> String
|
||||
on toUpper(str)
|
||||
set ca to current application
|
||||
((ca's NSString's stringWithString:(str))'s ¬
|
||||
uppercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
|
||||
end toUpper
|
||||
|
||||
-- A list of functions applied to a list of arguments
|
||||
-- (<*> | ap) :: [(a -> b)] -> [a] -> [b]
|
||||
on ap(fs, xs)
|
||||
set {nf, nx} to {length of fs, length of xs}
|
||||
set lst to {}
|
||||
repeat with i from 1 to nf
|
||||
tell mReturn(item i of fs)
|
||||
repeat with j from 1 to nx
|
||||
set end of lst to |λ|(contents of (item j of xs))
|
||||
end repeat
|
||||
end tell
|
||||
end repeat
|
||||
return lst
|
||||
end ap
|
||||
|
||||
-- Lift 2nd class handler function into 1st class script wrapper
|
||||
-- mReturn :: Handler -> Script
|
||||
|
|
@ -57,7 +55,7 @@ on mReturn(f)
|
|||
f
|
||||
else
|
||||
script
|
||||
property lambda : f
|
||||
property |λ| : f
|
||||
end script
|
||||
end if
|
||||
end mReturn
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"ALPHABETA ΑΒΓΔΕΖΗΘ", "alphabeta αβγδεζηθ", "Alphabeta Αβγδεζηθ"}
|
||||
{"alphabeta αβγδεζηθ", "Alphabeta Αβγδεζηθ", "ALPHABETA ΑΒΓΔΕΖΗΘ"}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
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$)
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
#import system.
|
||||
#import system'culture.
|
||||
import system'culture.
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
#var s1 := "alphaBETA".
|
||||
var s1 := "alphaBETA".
|
||||
|
||||
// Alternative 1
|
||||
console writeLine:(s1::caseLiteralOp lowerCase).
|
||||
console writeLine:(s1::caseLiteralOp upperCase).
|
||||
console writeLine(s1~caseLiteralOp lowerCase).
|
||||
console writeLine(s1~caseLiteralOp upperCase).
|
||||
|
||||
// Alternative 2
|
||||
console writeLine:(s1 toLower &locale:currentLocale).
|
||||
console writeLine:(s1 toUpper &locale:currentLocale).
|
||||
console writeLine(s1 toLower locale:currentLocale).
|
||||
console writeLine(s1 toUpper locale:currentLocale).
|
||||
console readChar.
|
||||
].
|
||||
|
|
|
|||
3
Task/String-case/Fortran/string-case-3.f
Normal file
3
Task/String-case/Fortran/string-case-3.f
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
DO I = 1,LEN(TEXT)
|
||||
TEXT(I:I) = XLATUC(ICHAR(TEXT(I:I)))
|
||||
END DO
|
||||
7
Task/String-case/Gambas/string-case.gambas
Normal file
7
Task/String-case/Gambas/string-case.gambas
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Public Sub Main()
|
||||
Dim sString As String = "alphaBETA "
|
||||
|
||||
Print UCase(sString)
|
||||
Print LCase(sString)
|
||||
|
||||
End
|
||||
9
Task/String-case/Kotlin/string-case.kotlin
Normal file
9
Task/String-case/Kotlin/string-case.kotlin
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val s = "alphaBETA"
|
||||
println(s.toUpperCase())
|
||||
println(s.toLowerCase())
|
||||
println(s.capitalize())
|
||||
println(s.decapitalize())
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
input$ ="alphaBETA"
|
||||
|
||||
print input$
|
||||
print upper$( input$)
|
||||
print lower$( input$)
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
echo -ag $upper(alphaBETA)
|
||||
echo -ag $lower(alphaBETA)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
import strutils
|
||||
|
||||
var s: string = "alphaBETA_123"
|
||||
echo s," as upper case: ", toUpper(s)
|
||||
echo s," as lower case: ", toLower(s)
|
||||
echo s," as Capitalized: ", capitalize(s)
|
||||
echo s," as normal case: ", normalize(s) # remove underscores, toLower
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
string s="alphaBETA"
|
||||
|
||||
print lcase(s) " "+
|
||||
ucase(s) " "+
|
||||
ucase(left(s,1))+mid(s,2) 'capitalised
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<@ ENU$$$LSTPSTLITLIT>UPP|
|
||||
[<@ SAYELTLST>...</@>] <@ SAYHLPELTLST>...</@><@ DEFKEYELTLST>__SuperMacro|...</@>
|
||||
<@ SAY&&&LIT>alphaBETA</@>
|
||||
|
||||
</@>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<# ENUMERATION LAMBDA LIST PEERSET LITERAL LITERAL>UPP|
|
||||
[<# SAY ELEMENT LIST>...</#>] <# SAY HELP ELEMENT LIST>...</#><# DEFINE KEYWORD ELEMENT LIST>__SuperMacro|...</#>
|
||||
<# SAY SUPERMACRO LITERAL>alphaBETA</#>
|
||||
|
||||
</#>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
s$ = "alphaBETA"
|
||||
upper$ = UCase(s$) ;uppercase
|
||||
lower$ = LCase(s$) ;lowercase
|
||||
1
Task/String-case/Ruby/string-case-2.rb
Normal file
1
Task/String-case/Ruby/string-case-2.rb
Normal file
|
|
@ -0,0 +1 @@
|
|||
'ĥåçýджк'.upcase # => "ĤÅÇÝДЖК"
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
a$ ="alphaBETA"
|
||||
|
||||
print a$ '=> alphaBETA
|
||||
print upper$(a$) '=> ALPHABETA
|
||||
print lower$(a$) '=> alphabeta
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
// Rust 0.9
|
||||
use std::ascii::StrAsciiExt;
|
||||
|
||||
"alphaBeta".to_ascii_upper();
|
||||
"alphaBeta".to_ascii_lower();
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
// Rust 1.0 Alpha
|
||||
fn main() {
|
||||
let s = "jalapeño";
|
||||
println!("{}", s.chars().map(|c| c.to_uppercase()).collect::<String>());
|
||||
}
|
||||
5
Task/String-case/Stata/string-case-1.stata
Normal file
5
Task/String-case/Stata/string-case-1.stata
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
. scalar s="alphaBETA"
|
||||
. di strupper(s)
|
||||
ALPHABETA
|
||||
. di strlower(s)
|
||||
alphabeta
|
||||
6
Task/String-case/Stata/string-case-2.stata
Normal file
6
Task/String-case/Stata/string-case-2.stata
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
. scalar a="Ἐν ἀρχῇ ἐποίησεν ὁ θεὸς τὸν οὐρανὸν καὶ τὴν γῆν"
|
||||
. scalar b=ustrupper(a)
|
||||
. di b
|
||||
ἘΝ ἈΡΧΗ͂Ι ἘΠΟΊΗΣΕΝ Ὁ ΘΕῸΣ ΤῸΝ ΟΥ̓ΡΑΝῸΝ ΚΑῚ ΤῊΝ ΓΗ͂Ν
|
||||
. di ustrlower(b)
|
||||
ἐν ἀρχῆι ἐποίησεν ὁ θεὸς τὸν οὐρανὸν καὶ τὴν γῆν
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
:"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
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
' Define 's'
|
||||
Dim s AS String = "alphaBETA"
|
||||
|
||||
' Change 's' to Upper Case.
|
||||
s = s.ToUpper()
|
||||
|
||||
' Change 's' to Lower Case.
|
||||
s = s.ToLower()
|
||||
3
Task/String-case/Zkl/string-case.zkl
Normal file
3
Task/String-case/Zkl/string-case.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s:="alphaBETA";
|
||||
s.toLower(); //--> "alphabeta"
|
||||
s.toUpper(); //--> "ALPHABETA"
|
||||
Loading…
Add table
Add a link
Reference in a new issue