Sign in to follow this  
Followers 0
iamtheky

map examples - (non standard)

2 posts in this topic

#1 ·  Posted (edited)

I am back to playing with map, trying some new thoughts and will place the working ones here as my other thread is now old and moldy ( and wandered into conjecture).

feel free to post your own and play along with my examples, first up:

MapAppend for setting values when declaring a Key, and retrieval

#include<array.au3>

local $mMap[]
$mMap['TestCat'] = MapAppend($mMap , 'Entry 1 about Cat') & "|" & MapAppend($mMap , 'Entry 2 about cat') & "|" & MapAppend($mMap , 'Entry 3 about cat')
$mMap['TestDog'] = MapAppend($mMap , 'Entry 1 about Dog')
$mMap['TestFish'] = MapAppend($mMap , 'Only entry about a Fish')

_ArrayDisplay(_MapAppToArray($mMap))


Func _MapAppToArray($map)

    $aMap = mapkeys($map)

        for $i = 0 to ubound($aMap) - 1
            If IsNumber($aMap[$i]) Then $aMap[$i] = $map[$aMap[$i]]
        Next

return $aMap

EndFunc ;_MapAppToArray

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



#2 ·  Posted

Same as above, but with empty line delimiters between keys (this helps me manipulate K/V sets in the array, but wanted to keep it separate in case it ends up fruitless)

#include<array.au3>

local $mMap[]
$mMap['TestCat'] = MapAppend($mMap , 'Entry 1 about Cat') & "|" & MapAppend($mMap , 'Entry 2 about cat') & "|" & MapAppend($mMap , 'Entry 3 about cat')
$mMap['TestDog'] = MapAppend($mMap , 'Entry 1 about Dog')
$mMap['TestFish'] = MapAppend($mMap , 'Only entry about a Fish')

_ArrayDisplay(_MapAppToArray($mMap))


Func _MapAppToArray($map)

    $aMap = mapkeys($map)

        for $i = ubound($aMap) - 1 to 1 step -1

            If IsNumber($aMap[$i]) Then
                $aMap[$i] = $map[$aMap[$i]]
            Else
                _ArrayInsert($aMap , $i , "")
            EndIf

        Next

return $aMap

EndFunc ;_MapAppToArray

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0