Logo

Programming-Idioms

History of Idiom 112 > diff from v7 to v8

Edit summary for version 8 by :
New Prolog implementation by user [Boris]

Version 7

2016-02-16, 18:11:06

Version 8

2016-02-16, 19:13:24

Idiom #112 Iterate over map entries, ordered by keys

Print each key k with its value x from an associative array mymap, in ascending order of k.

Idiom #112 Iterate over map entries, ordered by keys

Print each key k with its value x from an associative array mymap, in ascending order of k.

Code
dict_pairs(D, _, Ps),
forall(member(K-V, Ps),
       format("~w:~w~n", [K, V]))
Comments bubble
Map a dict to an ordered list of pairs, and print them to standard output using forall
Doc URL
swi-prolog.org
Demo URL
http://swish.swi-prolog.org/p/RUeUJUSI.swinb