ext/preprocessor/seq/transform.bi

This file is part of the <ext/Preprocessor> library API, and can be directly included by user programs.

Summary
ext/preprocessor/seq/transform.biThis file is part of the <ext/Preprocessor> library API, and can be directly included by user programs.
LicenseCopyright © 2007-2011, FreeBASIC Extended Library Development Group Copyright © 2002, Paul Mensonides
Macros
fbextPP_SeqTransformTransforms the elements of a sequence.

License

Copyright © 2007-2011, FreeBASIC Extended Library Development Group Copyright © 2002, Paul Mensonides

Distributed under the Boost Software License, Version 1.0.  See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com/p/fb-extended-lib/wiki/License

Macros

fbextPP_SeqTransform

# define fbextPP_SeqTransform(
   m,
   data,
   seq
) FBEXT_PP_SEQ_TAIL(FBEXT_PP_TUPLE_ELEM(3, 2, FBEXT_PP_SEQ_FOLDLEFT(fbextPP_SeqTransform_O, (m, data, (__)), seq)))

Transforms the elements of a sequence.

Parameters

mA user-defined macro that is called for every element in the sequence.  It has the form m(data, elem), where data is auxilliary data passed to fbextPP_SeqTransform, and elem is the current element.  This macro should return a new element.
dataAuxilliary data that is passed to the user-defined tranformation macro.
seqThe sequence to transform.

Description

Given a sequence (a)(b)(c)(d), this macro will expand to (m(data, a)) (m(data, b)) (m(data, c)) (m(data, d)).

Example

# include once "ext/preprocessor/seq/transform.bi"

# define SEQ (5)(3)(1)(4)
# define M(data, elem) FBEXT_PP_INC(elem)

# define RESULT FBEXT_PP_SEQ_TRANFORM(M, __, SEQ)
' RESULT is defined as (6)(4)(2)(5)
# define fbextPP_SeqTransform(
   m,
   data,
   seq
) FBEXT_PP_SEQ_TAIL(FBEXT_PP_TUPLE_ELEM(3, 2, FBEXT_PP_SEQ_FOLDLEFT(fbextPP_SeqTransform_O, (m, data, (__)), seq)))
Transforms the elements of a sequence.