[erlang-questions] Cleaning up code
Hugo Mills
hugo@REDACTED
Thu Jan 31 15:30:41 CET 2019
On Thu, Jan 31, 2019 at 09:20:43AM -0500, Donald Steven wrote:
> I need several large maps whose data will need to be accessed and
> updated in a number of functions. I've defined them in main() just
> to get started, but they're so extensive that they swamp the
> readability of main(). I haven't found a way to "include" them as
> 1) erlang won't accept simple file inclusion anywhere (like m4) and
> 2) my attempt to define a map in an .hrl file (like a -record
> definition), as in:
>
> keywords = #( ...}. or Keywords = #( ...}.
>
> just produces error messages. I could use m4, but ...
>
> Any suggestions? Thanks.
It's not clear how you're using the data, but that sounds like
either a ETS table, or a separate server process to manage the data in
each map.
If you're only concerned about the size of the initialisation for
each map, then you could just define them in a function and call that
in your main():
main() ->
Map1 = init_map1(),
...
init_map1() ->
#{a => 3, b => 4, ...}.
Hugo.
--
Hugo Mills | The last man on Earth sat in a room. Suddenly, there
hugo@REDACTED carfax.org.uk | was a knock at the door.
http://carfax.org.uk/ |
PGP: E2AB1DE4 | Frederic Brown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190131/a37ed46a/attachment.bin>
More information about the erlang-questions
mailing list