On Mon, Jun 27, 2016 at 7:48 AM, Adriano Ferreira via swift-users
<[email protected]> wrote:
> // Swift 3
>
> func quickSort(_ array: [Int]) -> [Int] {
> guard array.count > 1 else {
> return array
> }
>
> let (pivot, rest) = (array.first!, array.dropFirst())
>
> let lessThan = rest.filter({ $0 < pivot })
> let greaterThanOrEqual = rest.filter({ $0 >= pivot })
>
> // Cannot use ‘[Int]' here, as in Swift 2.2
> // Error says 'Int' is not convertible to '[Int]'
> let pivotArray = [pivot]
> return quickSort(lessThan) + pivotArray + quickSort(greaterThanOrEqual)
> }
Hi Adriano,
This code compiles with the current git master. Could you
double-check and post the exact error you are getting?
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <[email protected]>*/
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users