Sidef
view release on metacpan or search on metacpan
lib/Sidef/Module/Func.pod view on Meta::CPAN
=over 4
=item * Perl arrays â C<Sidef::Types::Array::Array>
=item * Perl hashes â C<Sidef::Types::Hash::Hash>
=item * Perl code refs â C<Sidef::Types::Block::Block>
=item * Numeric scalars â C<Sidef::Types::Number::Number>
=item * String scalars â C<Sidef::Types::String::String>
=item * Blessed Perl objects â C<Sidef::Module::OO>
=item * Multiple return values â C<Sidef::Types::Array::Array> in scalar context, individual Sidef values in list context
=back
B<Example:>
var lu = frequire('List::Util')
var total = lu.sum(1, 2, 3, 4, 5)
say total # => 15
=head1 ADVANCED EXAMPLES
=head2 Working with POSIX Functions
var posix = frequire('POSIX')
say posix.floor(2.9) # => 2
say posix.ceil(2.1) # => 3
say posix.round(2.5) # => 3
say posix.fabs(-3.14) # => 3.14
say posix.pow(2, 10) # => 1024
=head2 Using List::Util Reductions
var lu = frequire('List::Util')
var words = ['banana', 'apple', 'cherry']
var longest = lu.reduce({ |a, b| a.len > b.len ? a : b }, words...)
say longest # => banana
say lu.any({ _ > 5 }, 1, 3, 7, 2) # => true
say lu.all({ _ > 0 }, 1, 2, 3) # => true
say lu.none({ _ < 0 }, 1, 2, 3) # => true
=head2 Calling Module Functions with Sidef Values
# Sidef values are automatically converted to their underlying Perl representations
var su = frequire('Scalar::Util')
var num = 3.14
say su.looks_like_number(num) # => 1
=head2 Combining frequire with require
# Load a functional module and an OO module together
var list_util = frequire('List::Util')
var file_spec = require('File::Spec')
var values = [5, 2, 8, 1, 9, 3]
say list_util.max(values...) # => 9
say list_util.min(values...) # => 1
say file_spec.catfile(file_spec.tmpdir, 'sidef.txt')
=head2 Using Data::Dumper for Debugging
var dd = frequire('Data::Dumper')
var data = [1, [2, 3], {key => 'value'}]
say dd.Dumper(data)
=head1 SEE ALSO
=over 4
=item * L<Sidef::Module::OO> - Object-oriented interface for Perl modules
=item * L<Sidef::Types::Perl::Perl> - Evaluating Perl code and converting data structures
=item * L<Sidef::Object::Convert> - Conversion helpers (C<to_caller> / C<to_fcaller>)
=item * L<Sidef::Types::String::String> - The C<require> and C<frequire> string methods
=back
=cut
( run in 0.498 second using v1.01-cache-2.11-cpan-81fc1098f69 )