| … | … | @@ -1,46 +0,0 @@ |
| 1 | | /* |
| 2 | | * opencog/util/dorepeat.h |
| 3 | | * |
| 4 | | * Copyright (C) 2002-2007 Novamente LLC |
| 5 | | * All Rights Reserved |
| 6 | | * |
| 7 | | * This program is free software; you can redistribute it and/or modify |
| 8 | | * it under the terms of the GNU Affero General Public License v3 as |
| 9 | | * published by the Free Software Foundation and including the exceptions |
| 10 | | * at http://opencog.org/wiki/Licenses |
| 11 | | * |
| 12 | | * This program is distributed in the hope that it will be useful, |
| 13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | | * GNU General Public License for more details. |
| 16 | | * |
| 17 | | * You should have received a copy of the GNU Affero General Public License |
| 18 | | * along with this program; if not, write to: |
| 19 | | * Free Software Foundation, Inc., |
| 20 | | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | | */ |
| 22 | | |
| 23 | | #ifndef dorepeat |
| 24 | | /** \addtogroup grp_cogutil |
| 25 | | * @{ |
| 26 | | */ |
| 27 | | |
| 28 | | //!@{ |
| 29 | | //! helper for dorepeat(n) |
| 30 | | #define __DOREPEAT_CONCAT_3_( a, b ) a##b |
| 31 | | #define __DOREPEAT_CONCAT_2_( a, b ) __DOREPEAT_CONCAT_3_( a, b ) |
| 32 | | #define __DOREPEAT_CONCAT( a, b ) __DOREPEAT_CONCAT_2_( a, b ) |
| 33 | | #define __DOREPEAT_UNIQUE_NAME __DOREPEAT_CONCAT( DOREPEAT_UNIQUE_NAME_, __LINE__ ) |
| 34 | | //!@} |
| 35 | | |
| 36 | | //! dorepeat(n) foo |
| 37 | | /** repeats foo n times |
| 38 | | * maybe its mean to other people use this, but its certainly nicer that typing |
| 39 | | * for (int i=0;i<n;++i) when you never use i! |
| 40 | | */ |
| 41 | | #define dorepeat(N) \ |
| 42 | | for (unsigned int __DOREPEAT_UNIQUE_NAME=N; __DOREPEAT_UNIQUE_NAME>0;--__DOREPEAT_UNIQUE_NAME) |
| 43 | | |
| 44 | | /** @}*/ |
| 45 | | |
| 46 | | #endif |