iamtheky Posted May 2, 2017 Posted May 2, 2017 (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 May 2, 2017 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted May 2, 2017 Author Posted May 2, 2017 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 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now