Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: check possible combination of sum using given array

by Athanasius (Archbishop)
on Jul 09, 2019 at 06:27 UTC ( [id://11102584]=note: print w/replies, xml ) Need Help??


in reply to Re^2: check possible combination of sum using given array
in thread check possible combination of sum using given array

Hello karlgoethebier,

I just wondered if your sub find {# bla ...; return} compiles.

Are you thinking of the missing semicolon? From perlsyn#Simple-Statements:

Every simple statement must be terminated with a semicolon, unless it is the final statement in a block, in which case the semicolon is optional.

Or were you worried about having a return without an explicit return value? From return:

If no EXPR is given, returns an empty list in list context, the undefined value in scalar context, and (of course) nothing at all in void context.

The only call to find in bliako’s script is find($T, \@input, $target, \@solutions);, which is a call in void context. So the bare return simply causes find() to exit immediately, by-passing the rest of the code in the subroutine.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^4: check possible combination of sum using given array
by karlgoethebier (Abbot) on Jul 10, 2019 at 13:43 UTC

    Thanks for the explanation. I forgot that a sub is a block. Or can be regarded as a block. I didn’t worry about the "plain" return. Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11102584]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found