Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8beeb7f

Browse files
committed
Merge remote-tracking branch 'origin/master' into Swift-1.2
2 parents ac0380d + 71e7fa8 commit 8beeb7f

File tree

10 files changed

+465
-97
lines changed

10 files changed

+465
-97
lines changed

‎CHANGELOG.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# Change Log
2+
3+
## [Unreleased](https://github.com/pNre/ExSwift/tree/HEAD)
4+
5+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.9...HEAD)
6+
7+
**Closed issues:**
8+
9+
- NSDate addUnit stuff not working in ios7 [\#97](https://github.com/pNre/ExSwift/issues/97)
10+
11+
- weak support [\#96](https://github.com/pNre/ExSwift/issues/96)
12+
13+
- @synchronized support [\#95](https://github.com/pNre/ExSwift/issues/95)
14+
15+
- string.toDouble\(\) should accept "1.23e4" [\#94](https://github.com/pNre/ExSwift/issues/94)
16+
17+
- Compile fix for Swift 1.2 [\#90](https://github.com/pNre/ExSwift/issues/90)
18+
19+
- Swift-1.2 branch causing Segmentation fault: 11 [\#81](https://github.com/pNre/ExSwift/issues/81)
20+
21+
- Support for Swift 1.2 [\#80](https://github.com/pNre/ExSwift/issues/80)
22+
23+
- Still breaks range literals [\#71](https://github.com/pNre/ExSwift/issues/71)
24+
25+
- flatMap [\#62](https://github.com/pNre/ExSwift/issues/62)
26+
27+
- Nil filter method on array [\#59](https://github.com/pNre/ExSwift/issues/59)
28+
29+
- don't use array extension function [\#54](https://github.com/pNre/ExSwift/issues/54)
30+
31+
- Documentation small issue [\#53](https://github.com/pNre/ExSwift/issues/53)
32+
33+
- Spare the TakeSequence and TakeWhileSequence structs [\#52](https://github.com/pNre/ExSwift/issues/52)
34+
35+
- No one is merging in changes [\#49](https://github.com/pNre/ExSwift/issues/49)
36+
37+
- Swift Compile Error on Xcode 6.1 [\#38](https://github.com/pNre/ExSwift/issues/38)
38+
39+
- ExSwift breaks range subscripting [\#32](https://github.com/pNre/ExSwift/issues/32)
40+
41+
- skipWhile [\#31](https://github.com/pNre/ExSwift/issues/31)
42+
43+
**Merged pull requests:**
44+
45+
- Enhance Carthage Support [\#103](https://github.com/pNre/ExSwift/pull/103) ([nebhale](https://github.com/nebhale))
46+
47+
- Remove Deprecation Warnings [\#102](https://github.com/pNre/ExSwift/pull/102) ([nebhale](https://github.com/nebhale))
48+
49+
- Fix compatibility issue NSDate add [\#101](https://github.com/pNre/ExSwift/pull/101) ([PGLongo](https://github.com/PGLongo))
50+
51+
- Ex.cached for 1-arg functions. [\#93](https://github.com/pNre/ExSwift/pull/93) ([hiltonc](https://github.com/hiltonc))
52+
53+
- fixed for Xcode Version 6.3 beta 3 [\#89](https://github.com/pNre/ExSwift/pull/89) ([katopz](https://github.com/katopz))
54+
55+
- fix compiler error 'missing argument \#2' [\#88](https://github.com/pNre/ExSwift/pull/88) ([sebbean](https://github.com/sebbean))
56+
57+
- Format Number [\#86](https://github.com/pNre/ExSwift/pull/86) ([PGLongo](https://github.com/PGLongo))
58+
59+
- Fix compiler errors in second Xcode 6.3 beta \(6D532l\). [\#84](https://github.com/pNre/ExSwift/pull/84) ([JakobR](https://github.com/JakobR))
60+
61+
- Add Lisp's find method to Arrays. [\#83](https://github.com/pNre/ExSwift/pull/83) ([nickmshelley](https://github.com/nickmshelley))
62+
63+
- Add Bool extension [\#79](https://github.com/pNre/ExSwift/pull/79) ([davidman](https://github.com/davidman))
64+
65+
- Swift 1.2 \(Xcode 6.3\) support [\#78](https://github.com/pNre/ExSwift/pull/78) ([markusl](https://github.com/markusl))
66+
67+
- Made Framework and Unit Test iOS / OS X universal [\#76](https://github.com/pNre/ExSwift/pull/76) ([colemancda](https://github.com/colemancda))
68+
69+
- added method and tests [\#73](https://github.com/pNre/ExSwift/pull/73) ([michaeleisel](https://github.com/michaeleisel))
70+
71+
- added methods and tests [\#72](https://github.com/pNre/ExSwift/pull/72) ([michaeleisel](https://github.com/michaeleisel))
72+
73+
- added method and tests [\#70](https://github.com/pNre/ExSwift/pull/70) ([michaeleisel](https://github.com/michaeleisel))
74+
75+
- added method, tests, and whitespace changes [\#69](https://github.com/pNre/ExSwift/pull/69) ([michaeleisel](https://github.com/michaeleisel))
76+
77+
- Round to nearest [\#68](https://github.com/pNre/ExSwift/pull/68) ([michaeleisel](https://github.com/michaeleisel))
78+
79+
- added arithmetic methods [\#67](https://github.com/pNre/ExSwift/pull/67) ([michaeleisel](https://github.com/michaeleisel))
80+
81+
- added strideable methods [\#66](https://github.com/pNre/ExSwift/pull/66) ([michaeleisel](https://github.com/michaeleisel))
82+
83+
- removed unnecessary methods [\#65](https://github.com/pNre/ExSwift/pull/65) ([michaeleisel](https://github.com/michaeleisel))
84+
85+
- completely redid permutation generating [\#64](https://github.com/pNre/ExSwift/pull/64) ([michaeleisel](https://github.com/michaeleisel))
86+
87+
- Add shared schemes for installation by Carthage. [\#63](https://github.com/pNre/ExSwift/pull/63) ([yoichitgy](https://github.com/yoichitgy))
88+
89+
- Add getter and comparison to NSDate [\#61](https://github.com/pNre/ExSwift/pull/61) ([PGLongo](https://github.com/PGLongo))
90+
91+
- mapAccum for Array [\#60](https://github.com/pNre/ExSwift/pull/60) ([phatmann](https://github.com/phatmann))
92+
93+
- Added to\* methods to readme docs. [\#58](https://github.com/pNre/ExSwift/pull/58) ([mikeckennedy](https://github.com/mikeckennedy))
94+
95+
- Trimmed methods fail on string that contains only whitespace [\#57](https://github.com/pNre/ExSwift/pull/57) ([pizthewiz](https://github.com/pizthewiz))
96+
97+
- Add toNumeric \(e.g. toDouble\) conversions to string extensions [\#56](https://github.com/pNre/ExSwift/pull/56) ([mikeckennedy](https://github.com/mikeckennedy))
98+
99+
- Added overloaded ltrimmed and rtrimmed methods [\#55](https://github.com/pNre/ExSwift/pull/55) ([hhoangnl](https://github.com/hhoangnl))
100+
101+
- Update Dictionary.swift [\#51](https://github.com/pNre/ExSwift/pull/51) ([davidman](https://github.com/davidman))
102+
103+
- Added Charater extension [\#50](https://github.com/pNre/ExSwift/pull/50) ([cennydavidsson](https://github.com/cennydavidsson))
104+
105+
- Repeated permutations [\#48](https://github.com/pNre/ExSwift/pull/48) ([michaeleisel](https://github.com/michaeleisel))
106+
107+
- Added NSDate methods [\#47](https://github.com/pNre/ExSwift/pull/47) ([PGLongo](https://github.com/PGLongo))
108+
109+
- Repeated combinations [\#46](https://github.com/pNre/ExSwift/pull/46) ([michaeleisel](https://github.com/michaeleisel))
110+
111+
- Fill [\#45](https://github.com/pNre/ExSwift/pull/45) ([michaeleisel](https://github.com/michaeleisel))
112+
113+
- Transpose [\#44](https://github.com/pNre/ExSwift/pull/44) ([michaeleisel](https://github.com/michaeleisel))
114+
115+
- Permutations [\#43](https://github.com/pNre/ExSwift/pull/43) ([michaeleisel](https://github.com/michaeleisel))
116+
117+
- added combinations method [\#42](https://github.com/pNre/ExSwift/pull/42) ([michaeleisel](https://github.com/michaeleisel))
118+
119+
- Unique by method [\#41](https://github.com/pNre/ExSwift/pull/41) ([michaeleisel](https://github.com/michaeleisel))
120+
121+
- Added UIColor extension [\#39](https://github.com/pNre/ExSwift/pull/39) ([PGLongo](https://github.com/PGLongo))
122+
123+
- Added minBy and maxBy methods [\#37](https://github.com/pNre/ExSwift/pull/37) ([michaeleisel](https://github.com/michaeleisel))
124+
125+
- Add installation instruction [\#35](https://github.com/pNre/ExSwift/pull/35) ([kostiakoval](https://github.com/kostiakoval))
126+
127+
- the script can generation a Framework of StaticLibrary [\#30](https://github.com/pNre/ExSwift/pull/30) ([zhfish](https://github.com/zhfish))
128+
129+
## [0.1.9](https://github.com/pNre/ExSwift/tree/0.1.9) (2014年08月20日)
130+
131+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.8...0.1.9)
132+
133+
**Merged pull requests:**
134+
135+
- Added count methods [\#27](https://github.com/pNre/ExSwift/pull/27) ([jmnavarro](https://github.com/jmnavarro))
136+
137+
## [0.1.8](https://github.com/pNre/ExSwift/tree/0.1.8) (2014年08月05日)
138+
139+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.7...0.1.8)
140+
141+
**Closed issues:**
142+
143+
- ExSwift broken in beta 5 [\#26](https://github.com/pNre/ExSwift/issues/26)
144+
145+
- Single index string subscripting results in compiler error [\#25](https://github.com/pNre/ExSwift/issues/25)
146+
147+
- Array.indexOf not working with \[UInt\] [\#21](https://github.com/pNre/ExSwift/issues/21)
148+
149+
**Merged pull requests:**
150+
151+
- Changes =~ to take regular expression. [\#22](https://github.com/pNre/ExSwift/pull/22) ([nomothetis](https://github.com/nomothetis))
152+
153+
## [0.1.7](https://github.com/pNre/ExSwift/tree/0.1.7) (2014年07月25日)
154+
155+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.6...0.1.7)
156+
157+
**Closed issues:**
158+
159+
- Breaks in Xcode6-Beta4 [\#19](https://github.com/pNre/ExSwift/issues/19)
160+
161+
**Merged pull requests:**
162+
163+
- Added access modifiers [\#20](https://github.com/pNre/ExSwift/pull/20) ([vmartinelli](https://github.com/vmartinelli))
164+
165+
## [0.1.6](https://github.com/pNre/ExSwift/tree/0.1.6) (2014年07月22日)
166+
167+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.5...0.1.6)
168+
169+
## [0.1.5](https://github.com/pNre/ExSwift/tree/0.1.5) (2014年07月19日)
170+
171+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.4...0.1.5)
172+
173+
**Closed issues:**
174+
175+
- Support for Double / Integer [\#18](https://github.com/pNre/ExSwift/issues/18)
176+
177+
- Help, got so many compile errors [\#17](https://github.com/pNre/ExSwift/issues/17)
178+
179+
## [0.1.4](https://github.com/pNre/ExSwift/tree/0.1.4) (2014年07月07日)
180+
181+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.3...0.1.4)
182+
183+
**Merged pull requests:**
184+
185+
- used shuffle\(\) to shuffle in shuffled\(\) [\#16](https://github.com/pNre/ExSwift/pull/16) ([natecook1000](https://github.com/natecook1000))
186+
187+
## [0.1.3](https://github.com/pNre/ExSwift/tree/0.1.3) (2014年07月03日)
188+
189+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.2...0.1.3)
190+
191+
**Merged pull requests:**
192+
193+
- Sequence ops [\#15](https://github.com/pNre/ExSwift/pull/15) ([ColinEberhardt](https://github.com/ColinEberhardt))
194+
195+
- Added a toDictionary method [\#13](https://github.com/pNre/ExSwift/pull/13) ([ColinEberhardt](https://github.com/ColinEberhardt))
196+
197+
- Added a sortBy method [\#12](https://github.com/pNre/ExSwift/pull/12) ([ColinEberhardt](https://github.com/ColinEberhardt))
198+
199+
- Define iOS module with the same name as OS X, cleanup duplicate files [\#11](https://github.com/pNre/ExSwift/pull/11) ([garnett](https://github.com/garnett))
200+
201+
- Simplify partition tests [\#10](https://github.com/pNre/ExSwift/pull/10) ([zolrath](https://github.com/zolrath))
202+
203+
## [0.1.2](https://github.com/pNre/ExSwift/tree/0.1.2) (2014年06月18日)
204+
205+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.1...0.1.2)
206+
207+
**Fixed bugs:**
208+
209+
- Compile error: Access String array by subscript [\#6](https://github.com/pNre/ExSwift/issues/6)
210+
211+
**Closed issues:**
212+
213+
- Result of indexOf, lastIndexOf should be an optional [\#8](https://github.com/pNre/ExSwift/issues/8)
214+
215+
**Merged pull requests:**
216+
217+
- Add .gitignore, add iOS Framework + tests target [\#7](https://github.com/pNre/ExSwift/pull/7) ([garnett](https://github.com/garnett))
218+
219+
- return Int? in indexOf, lastIndexOf [\#9](https://github.com/pNre/ExSwift/pull/9) ([garnett](https://github.com/garnett))
220+
221+
- Add partition, partitionAll, and partitionBy [\#5](https://github.com/pNre/ExSwift/pull/5) ([zolrath](https://github.com/zolrath))
222+
223+
- Add takeWhile and skipWhile to Array [\#4](https://github.com/pNre/ExSwift/pull/4) ([zolrath](https://github.com/zolrath))
224+
225+
## [0.1.1](https://github.com/pNre/ExSwift/tree/0.1.1) (2014年06月11日)
226+
227+
[Full Changelog](https://github.com/pNre/ExSwift/compare/0.1.0...0.1.1)
228+
229+
**Merged pull requests:**
230+
231+
- Use if let syntax for Dictionary {group, count}by [\#3](https://github.com/pNre/ExSwift/pull/3) ([zolrath](https://github.com/zolrath))
232+
233+
- Use if let syntax for groupBy and countBy [\#2](https://github.com/pNre/ExSwift/pull/2) ([zolrath](https://github.com/zolrath))
234+
235+
## [0.1.0](https://github.com/pNre/ExSwift/tree/0.1.0) (2014年06月10日)
236+
237+
238+
239+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

‎ExSwift.xcodeproj/project.pbxproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585
CC633BA61A37142900341557 /* CharacterExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC633BA51A37142900341557 /* CharacterExtensionsTests.swift */; };
8686
CC633BA71A37144E00341557 /* Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8C1D701A365CA6003D386E /* Character.swift */; };
8787
CC8C1D711A365CA6003D386E /* Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC8C1D701A365CA6003D386E /* Character.swift */; };
88+
3C0AB97E195C7FC20009BDA0 /* ExSwiftSequenceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0AB97C195C7FBC0009BDA0 /* ExSwiftSequenceTests.swift */; };
89+
6CB1F15F1A8AB867002EA767 /* Bool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB1F15E1A8AB867002EA767 /* Bool.swift */; };
90+
6CB1F1611A8AB8D3002EA767 /* ExSwiftBoolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB1F1601A8AB8D3002EA767 /* ExSwiftBoolTests.swift */; };
91+
6CB1F1621A8AB979002EA767 /* ExSwiftBoolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB1F1601A8AB8D3002EA767 /* ExSwiftBoolTests.swift */; };
92+
6CB1F1631A8ABA1A002EA767 /* Bool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB1F15E1A8AB867002EA767 /* Bool.swift */; };
93+
6CB1F1641A8ABA1A002EA767 /* Bool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB1F15E1A8AB867002EA767 /* Bool.swift */; };
94+
6CB1F1661A8ABA1C002EA767 /* Bool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB1F15E1A8AB867002EA767 /* Bool.swift */; };
8895
/* End PBXBuildFile section */
8996

9097
/* Begin PBXContainerItemProxy section */
@@ -135,6 +142,7 @@
135142
CC633BA51A37142900341557 /* CharacterExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterExtensionsTests.swift; sourceTree = "<group>"; };
136143
CC8C1D701A365CA6003D386E /* Character.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Character.swift; sourceTree = "<group>"; };
137144
FA8EE3398AF8D20E3CE7A698 /* Pods-ExSwiftTests-OSX.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExSwiftTests-OSX.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExSwiftTests-OSX/Pods-ExSwiftTests-OSX.debug.xcconfig"; sourceTree = "<group>"; };
145+
6CB1F15E1A8AB867002EA767 /* Bool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bool.swift; sourceTree = "<group>"; };
138146
/* End PBXFileReference section */
139147

140148
/* Begin PBXFrameworksBuildPhase section */
@@ -210,6 +218,7 @@
210218
1E11AFB11943225B006BCE48 /* String.swift */,
211219
1EC241FB1946E91B0047109A /* NSArray.swift */,
212220
12168FC91A22852300ED4105 /* NSDate.swift */,
221+
6CB1F15E1A8AB867002EA767 /* Bool.swift */,
213222
1E11AF891943222D006BCE48 /* ExSwift.h */,
214223
1E11AF871943222D006BCE48 /* Supporting Files */,
215224
);
@@ -550,6 +559,7 @@
550559
3C0AB978195C7FAF0009BDA0 /* Sequence.swift in Sources */,
551560
1E11AFB21943225B006BCE48 /* Array.swift in Sources */,
552561
1ED536841943863100BDA94E /* ExSwift.swift in Sources */,
562+
6CB1F15F1A8AB867002EA767 /* Bool.swift in Sources */,
553563
1E11AFB41943225B006BCE48 /* Dictionary.swift in Sources */,
554564
1E11AFB61943225B006BCE48 /* Float.swift in Sources */,
555565
1E11AFB81943225B006BCE48 /* Int.swift in Sources */,
@@ -579,6 +589,7 @@
579589
2EB34F0C195473AC00A8D2AF /* NSArray.swift in Sources */,
580590
CC633BA71A37144E00341557 /* Character.swift in Sources */,
581591
2EB34F05195473AC00A8D2AF /* ExSwift.swift in Sources */,
592+
6CB1F1631A8ABA1A002EA767 /* Bool.swift in Sources */,
582593
2EB34F08195473AC00A8D2AF /* Float.swift in Sources */,
583594
12168FCD1A2285A900ED4105 /* NSDateExtensionsTests.swift in Sources */,
584595
1E11AFAB19432236006BCE48 /* StringExtensionsTests.swift in Sources */,

‎ExSwift/Array.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@ internal extension Array {
124124
@availability(*, unavailable, message="use the 'last' property instead") func last () -> Element? {
125125
return last
126126
}
127+
128+
/**
129+
First occurrence of item, if found.
130+
131+
:param: item The item to search for
132+
:returns: Matched item or nil
133+
*/
134+
func find <U: Equatable> (item: U) -> T? {
135+
if let index = indexOf(item) {
136+
return self[index]
137+
}
138+
139+
return nil
140+
}
141+
142+
/**
143+
First item that meets the condition.
144+
145+
:param: condition A function which returns a boolean if an element satisfies a given condition or not.
146+
:returns: First matched item or nil
147+
*/
148+
func find (condition: Element -> Bool) -> Element? {
149+
return takeFirst(condition)
150+
}
127151

128152
/**
129153
Index of the first occurrence of item, if found.
@@ -133,7 +157,7 @@ internal extension Array {
133157
*/
134158
func indexOf <U: Equatable> (item: U) -> Int? {
135159
if item is Element {
136-
return find(unsafeBitCast(self, [U].self), item)
160+
return Swift.find(unsafeBitCast(self, [U].self), item)
137161
}
138162

139163
return nil

‎ExSwift/Bool.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// Bool.swift
3+
// ExSwift
4+
//
5+
// Created by Hernandez Alvarez, David on 2/10/15.
6+
// Copyright (c) 2015 pNre. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
extension Bool {
12+
13+
mutating func toggle() -> Bool {
14+
self = !self
15+
return self
16+
}
17+
18+
}

‎ExSwift/ExSwift.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ public class ExSwift {
140140
}
141141
}
142142

143+
/**
144+
Creates a wrapper for function that caches the result of function's invocations.
145+
146+
:param: function Function with one parameter to cache
147+
:returns: Wrapper function
148+
*/
149+
public class func cached <P: Hashable, R> (function: P -> R) -> (P -> R) {
150+
var cache = [P:R]()
151+
152+
return { (param: P) -> R in
153+
let key = param
154+
155+
if let cachedValue = cache[key] {
156+
return cachedValue
157+
} else {
158+
let value = function(param)
159+
cache[key] = value
160+
return value
161+
}
162+
}
163+
}
164+
143165
/**
144166
Creates a wrapper for function that caches the result of function's invocations.
145167

@@ -154,19 +176,18 @@ public class ExSwift {
154176
var cache = [P:R]()
155177

156178
return { (params: P...) -> R in
157-
158179
let adaptedFunction = unsafeBitCast(function, Function.self)
159180
let adaptedHash = unsafeBitCast(hash, Hash.self)
160181

161182
let key = adaptedHash(params)
162183

163184
if let cachedValue = cache[key] {
164185
return cachedValue
186+
} else {
187+
let value = adaptedFunction(params)
188+
cache[key] = value
189+
return value
165190
}
166-
167-
cache[key] = adaptedFunction(params)
168-
169-
return cache[key]!
170191
}
171192
}
172193

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /