Jump to content

map examples - (non standard)


iamtheky
 Share

Recommended Posts

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

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

Link to comment
Share on other sites

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

 

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...