Swift标准函数
标签:
abs(-1)==1
abs(-42)==42
abs(42)==42
contains(languages,"Swift")==true
contains(languages,"Java")==false
contains([29,85,42,96,75],42)==true
dump(languages)
//Prints:
//?2elements
//-[0]:Swift
//-[1]:Objective-C
equal(languages,["Swift","Objective-C"])==true
varoldLanguages=dropFirst(languages)
equal(oldLanguages,["Objective-C"])==true
-
@H_502_170@foriinfilter(1...100,{$0%10==0})
- { @H_502_170@//10,20,30,...
- println(i) @H_502_170@assert(contains([10,40,50,60,70,80,90,100],i))
- }
find(languages,"Objective-C")==1
find(languages,"Java")==nil
find([29,42)==2
equal(indices([29,42]),[0,1,2])
foriinindices([29,42]){
//0,2
println(i)
}
join(":",["A","B","C"])=="A:B:C"
varlanguages=["Swift","Objective-C"]
join("/",languages)=="Swift/Objective-C"
max(0,1)==1
max(8,2,3)==8
-
@H_502_170@maxElement(1...10)==10
- varlanguages=["Swift","Objective-C"] @H_502_170@maxElement(languages)=="Swift"
minElement(1...10)==1
varlanguages=["Swift","Objective-C"]
minElement(languages)=="Objective-C"
reduce(languages,"",{$0+$1})=="SwiftObjective-C"
reduce([10,5],{$0*$1})==1000
equal(reverse([1,3]),[3,1])
foriinreverse([1,3]){
//3,1
println(i)
}
startsWith("foobar","foo")==true
startsWith(10..100,10..15)==true
varlanguages=["Swift","Objective-C"]
startsWith(languages,["Swift"])==true
-
@H_502_170@abs(...)
- advance(...) @H_502_170@alignof(...)
- alignofValue(...) @H_502_170@assert(...)
- bridgeFromObjectiveC(...) @H_502_170@bridgeFromObjectiveCUnconditional(...)
- bridgeToObjectiveC(...) @H_502_170@bridgeToObjectiveCUnconditional(...)
- c_malloc_size(...) @H_502_170@c_memcpy(...)
- c_putchar(...) @H_502_170@contains(...)
- count(...) @H_502_170@countElements(...)
- countLeadingZeros(...) @H_502_170@debugPrint(...)
- debugPrintln(...) @H_502_170@distance(...)
- dropFirst(...) @H_502_170@dropLast(...)
- dump(...) @H_502_170@encodeBitsAsWords(...)
- enumerate(...) @H_502_170@equal(...)
- filter(...) @H_502_170@find(...)
- getBridgedObjectiveCType(...) @H_502_170@getVaList(...)
- indices(...) @H_502_170@insertionSort(...)
- isBridgedToObjectiveC(...) @H_502_170@isBridgedVerbatimToObjectiveC(...)
- isUniquelyReferenced(...) @H_502_170@join(...)
- lexicographicalCompare(...) @H_502_170@map(...)
- max(...) @H_502_170@maxElement(...)
- min(...) @H_502_170@minElement(...)
- numericCast(...) @H_502_170@partition(...)
- posix_read(...) @H_502_170@posix_write(...)
- print(...) @H_502_170@println(...)
- quickSort(...) @H_502_170@reduce(...)
- reflect(...) @H_502_170@reinterpretCast(...)
- reverse(...) @H_502_170@roundUpToAlignment(...)
- sizeof(...) @H_502_170@sizeofValue(...)
- sort(...) @H_502_170@split(...)
- startsWith(...) @H_502_170@strideof(...)
- strideofValue(...) @H_502_170@swap(...)
- swift_MagicMirrorData_summaryImpl(...) @H_502_170@swift_bufferAllocate(...)
- swift_keepAlive(...) @H_502_170@toString(...)
- transcode(...) @H_502_170@underestimateCount(...)
- unsafeReflect(...) @H_502_170@withExtendedLifetime(...)
- withObjectAtPlusZero(...) @H_502_170@withUnsafePointer(...)
- withUnsafePointerToObject(...) @H_502_170@withUnsafePointers(...)
- withVaList(...)
标签: