for var i=count-2; i>=0; --i
{
     if let nextControlPoint = firstControlPoints[i+1]
    {
        let controlPointX = (rhsArray[i].x.f - c[i] * nextControlPoint.x.f)/b[i]
        let controlPointY = (rhsArray[i].y.f - c[i] * nextControlPoint.y.f)/b[i]
    }
    z += 1
}
            Asked
            
        
        
            Active
            
        
            Viewed 91 times
        
    -1
            
            
         
    
    
        Luca Angeletti
        
- 58,465
- 13
- 121
- 148
 
    
    
        Neel Purohit
        
- 17
- 3
- 
                    3What did you try so far? Please post your code. – albert Aug 07 '18 at 12:22
- 
                    for i in 0..=0 { if let nextControlPoint = firstControlPoints[i+1] { let controlPointX = (rhsArray[i].x.f - c[i] * nextControlPoint.x.f)/b[i] let controlPointY = (rhsArray[i].y.f - c[i] * nextControlPoint.y.f)/b[i] firstControlPoints[i] = CGPoint(x: controlPointX, y: controlPointY) } z += 1 } – Neel Purohit Aug 07 '18 at 12:27
- 
                    https://www.weheartswift.com/loops/ refer this – Mahesh Dangar Aug 07 '18 at 12:27
1 Answers
3
            
            
        You can write something like this
if count > 1 {
    for i in (0...count-2).reversed() {
        print(i)
    }
}
The IF statement is needed because we cannot create a range where the first element is lower than the last one.
 
    
    
        Luca Angeletti
        
- 58,465
- 13
- 121
- 148