Mercurial > gemma
comparison pkg/common/delta.go @ 5688:6281c18b109f sr-v2
Finsh serializing v2 meshes.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 12 Feb 2024 02:27:41 +0100 |
parents | |
children | 9e9cedae718a |
comparison
equal
deleted
inserted
replaced
5687:8ff842858434 | 5688:6281c18b109f |
---|---|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 | |
2 // without warranty, see README.md and license for details. | |
3 // | |
4 // SPDX-License-Identifier: AGPL-3.0-or-later | |
5 // License-Filename: LICENSES/AGPL-3.0.txt | |
6 // | |
7 // Copyright (C) 2024 by via donau | |
8 // – Österreichische Wasserstraßen-Gesellschaft mbH | |
9 // Software engineering by Intevation GmbH | |
10 // | |
11 // Author(s): | |
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | |
13 | |
14 package common | |
15 | |
16 // Delta returns a function which returns its argument when called | |
17 // the first time and the delta to the last call afterwards. | |
18 func Delta() func(int64) int64 { | |
19 var last int64 | |
20 first := true | |
21 return func(x int64) (y int64) { | |
22 if first { | |
23 first = false | |
24 y = x | |
25 last = x | |
26 } else { | |
27 y = x - last | |
28 last = x | |
29 } | |
30 return | |
31 } | |
32 } |