Data::SExpression::Util - routines for processing linked lists
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
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:
Appends the list $other_list at the end of the list $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.
Reverses a list
Searches for $elt in $list and returns the first matching element (comparison is done via eq).
Marius Gavrilescu, <marius@ieval.ro>
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.
To install Data::SExpression::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::SExpression::Util
CPAN shell
perl -MCPAN -e shell install Data::SExpression::Util
For more information on module installation, please visit the detailed CPAN module installation guide.