| 1 |
// Copyright ©2011-2012 The bíogo Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package feat |
| 6 |
|
| 7 |
// Convert from 1-based to 0-based indexing |
| 8 |
func OneToZero(pos int) int { |
| 9 |
if pos == 0 { |
| 10 |
panic("feat: 1-based index == 0") |
| 11 |
} |
| 12 |
if pos > 0 { |
| 13 |
pos-- |
| 14 |
} |
| 15 |
|
| 16 |
return pos |
| 17 |
} |
| 18 |
|
| 19 |
// Convert from 0-based to 1-based indexing |
| 20 |
func ZeroToOne(pos int) int { |
| 21 |
if pos >= 0 { |
| 22 |
pos++ |
| 23 |
} |
| 24 |
|
| 25 |
return pos |
| 26 |
} |