Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Finding sum of numbers and storing it an Array

by tobyink (Canon)
on Sep 21, 2020 at 11:03 UTC ( [id://11121994]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Finding sum of numbers and storing it an Array
in thread Finding sum of numbers and storing it an Array

the thing is i am not allowed to use maps in this program only array

To be clear, in some programming languages, there's a data structure called a "Map". Java is one such language. It stores a mapping from one set of data (the keys) to another set of data (the values). Perhaps domain names to IP addresses:

( "foo.example.com" => "10.0.0.1", "bar.example.com" => "10.0.0.2", "baz.example.com" => "10.0.0.3", )

Perl doesn't have a native map datatype. For some purposes, Perl hashes can be used. But if the keys can't be reduced to strings, Perl hashes become trickier. (Tied hashes and fieldhashes can work around this limitation to an extent.)

The Perl map keyword doesn't have anything to do with Map data structures though. It operates on lists. (And an array is basically just a way of storing a list in a variable.)

Anything you do with map and grep, you can do with plain old loops, but map and grep are often clearer ways to express yourself.

A way to think of it might be: can you speak/write using only one-syllable words?

  • Yes, you can say all the things you want to say with the use of words that have just one sound part in them.
  • But polysyllabic words sometimes allow for more concise expression.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-25 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found