NAME
Data::SExpression::Util - routines for processing linked lists
SYNOPSIS
use Data::SExpression::Util qw/:all/;
my $list = cons 1, cons 2, cons 3, undef; # (1 2 3)
my $other_list = cons 4, cons 5, undef; # (4 5)
$list = append $list, $other_list; # $list is now (1 2 3 4 5)
say position 1, $list; # 0
say position 4, $list; # 3
say 'undef' unless defined position 0, $list; # undef
$list = rev $list; # (5 4 3 2 1)
$list = mapcar { $_ + 1 } $list; # (6 5 4 3 2)
say position 2, $list; # 4
DESCRIPTION
Data::SExpression::Util contains several routines for processing linked lists (represented Data::SExpression::Cons objects). These are analogous to Lisp functions with the same names.
Right now very few functions are implemented, more will come in the next version.
The list of functions is:
- append($list, $other_list)
-
Appends the list $other_list at the end of the list $list.
- mapcar { block } $list
-
Analogous to Perl's map function. Runs block with each element of the list $list as $_, and then returns a containing all of the result.
- rev($list)
-
Reverses a list
- position($elt, $list)
-
Searches for $elt in $list and returns the first matching element (comparison is done via eq).
AUTHOR
Marius Gavrilescu, <marius@ieval.ro>
COPYRIGHT AND LICENSE
Copyright (C) 2018 by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.