czardas Posted September 26, 2015 Share Posted September 26, 2015 (edited) You guys are inspiring me. I might have a go at a super arrayConcatenate function which doesn't care how many dimensions there are in either array. The concept is just to create the elements and add the data at the first available opportunity. It might be convenient to imagine a one dimension array as a multi-dimensional array with only one entry in all other dimensions, like so ==>$a1[2] ~ $a2[2][1] ~ $a3[2][1][1] ~ $a4[2][1][1][1] etc...All these arrays have exactly 2 elements. Needs further thought. Edited September 26, 2015 by czardas kcvinu 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kcvinu Posted September 26, 2015 Author Share Posted September 26, 2015 @czardas , That's great. An "array Concatenate function which doesn't care how many dimensions". czardas 1 Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
czardas Posted September 26, 2015 Share Posted September 26, 2015 (edited) It might turn out to be quite complicated but I'll have a go. Like I said I need to think about it first - edge case limitations on maximum available elements in all dimensions need to be tested. Then error checks can be put in place and the parsing can begin. The returned array will have the minimum number of dimensions needed to hold all the elements without corrupting the original ordered sequences. It sounds fun - in theory at least. Edited September 26, 2015 by czardas kcvinu 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
iamtheky Posted September 26, 2015 Share Posted September 26, 2015 i got cocky and jacked up columns the same way rows were jacked up before, I'll fix that during american football later. Rows should be fine though. kcvinu 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
iamtheky Posted September 26, 2015 Share Posted September 26, 2015 (edited) one more shot at this, I would assume that boundaries had been validated prior.expandcollapse popup#include <Array.au3> Local $aFirst[5][5] = [[5, 6, 7, 1, 0], [8, 9, 10, 1, 0], [11, 14, 15, 1, 0], [16, 17, 18, 1, 0] , [17, 17, 17, 17, 0]] Local $aSecond[4][5] = [[1, 3, 4, 4, 6] , [2, 6, 8, 4, 6] , [1, 3, 4, 4, 6] , [1, 3, 4, 4, 6]] ;~ _ArrayDisplay($aSecond) $timer = timerinit() $aRowSmash = _2Dsmash($aFirst , $aSecond, 0) $diff = timerdiff($timer) _ArrayDisplay($aRowSmash , $diff) $timer = timerinit() $aColumnSmash = _2Dsmash($aFirst , $aSecond, 1) $diff = timerdiff($timer) _ArrayDisplay($aColumnSmash , $diff) Func _2Dsmash($aBase , $aAdd , $flag = 0) If $flag = 0 Then redim $aBase[ubound($aBase) + ubound($aAdd)][ubound($aBase, 2)] For $k = 0 to ubound($aAdd) - 1 For $i = 0 to ubound($aBase , 2) - 1 $aBase[ubound($aBase) - ubound($aAdd) + $k][$i] = $aAdd[$k][$i] Next Next Else redim $aBase[ubound($aBase , 2)][ubound($aBase) + ubound($aAdd)] For $k = 0 to ubound($aAdd) - 1 For $i = 0 to ubound($aBase) - 1 $aBase[$i][ubound($aBase , 2) - ubound($aAdd) + $k] = $aAdd[$k][$i] Next Next EndIf return $aBase EndFunc ;2Dsmash Edited September 26, 2015 by boththose kcvinu 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
kcvinu Posted September 26, 2015 Author Share Posted September 26, 2015 @boththose i will check it after some time. I will inform you. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
iamtheky Posted September 26, 2015 Share Posted September 26, 2015 (edited) I am halfway there, as the the content doesnt matter so much as the declaration. And that could be fixed first thing in the func to redim both inputs to the max necessary value. But making dimensions not matter, that sounds like an astrophysics exercise for Czardas.Local $aFirst[5][9] = [[5, 5, 6, 7, 1], [8, 9, 10, 1, 0], [11, 14, 15, 1, 0], [16, 17, 18, 1, 0]] Local $aSecond[3][9] = [[1, 3, 4, 4, 6, 7, 8, 9 , 0] , [1, 3, 4, 6, 2, 3, 9] , [1 , 2 ,3]] Edited September 26, 2015 by boththose kcvinu 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
kcvinu Posted September 26, 2015 Author Share Posted September 26, 2015 (edited) Oh my god.. what is this.. I think we can't run our code with these type of arrays. Edited September 26, 2015 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
iamtheky Posted September 26, 2015 Share Posted September 26, 2015 (edited) I dont know a nice way to get rid of the blank row in the row array without just looping through it again, but the column add looks nice it is way unstable and there are edge cases for days that will break it. Edited September 26, 2015 by boththose grammar ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
kcvinu Posted September 27, 2015 Author Share Posted September 27, 2015 @boththose In most case we only need to add a 1D array to a 2D array. That's why i made the function. As @@czardas said, if it will accept arrays wthout bothering its dimension, then it will be a good feature. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
czardas Posted September 27, 2015 Share Posted September 27, 2015 (edited) I'm still thinking about this. It will take me some time (unfortunately) because I have many projects on the go already, but I intend to look at it in the near future. After some thought, testing multidimensional array limits may not be so straight forward and it may be best to allow the interpreter to throw an error when the number of elements max out. The reason is - I'm not sure if limits depend on syntax or not. $aForwards[1][2][3]...[n] may be different to $aBackwards[n][n-1][n-2]...[1]. Testing every possible case doesn't seem plausible. Edited September 27, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kcvinu Posted September 27, 2015 Author Share Posted September 27, 2015 @czardas , I think, we only need to face arrays with fixed elements for concantenating. So this is mu pseudo code.1. check the input arrays if they are 1D or 2D2. get the Ubound of those arrays. (Both row count and column count)3. If it is not matching row wise or column wise, then throw an error.4. If 1st array is 2D and 2nd array is 1D then --- Do the concantenation5. If 1st array is 2D and 2nd array is 2D then --- Do the concantenation6. If 1st array is 1D and 2nd array is 2D then --- Do the concantenation7. Return the resulted array Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
czardas Posted September 27, 2015 Share Posted September 27, 2015 (edited) Maybe I'll limit the number of dimensions. Matching dimensions isn't a priority. Edited September 27, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kcvinu Posted September 27, 2015 Author Share Posted September 27, 2015 OK, then we can check for dimensions and limit it to 2. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
czardas Posted September 28, 2015 Share Posted September 28, 2015 (edited) Something like this?expandcollapse popup#include <Array.au3> ; For _ArrayDisplay Local $aRet = _ArrConcat_Max2D("Hello", "World", 1) _ArrayDisplay($aRet) Local $a1 = [0,1,2] $aRet = _ArrConcat_Max2D($a1, $aRet) _ArrayDisplay($aRet) Local $a2 = [[3,4,5,6],[7,8],["A","B","C","D","E"],["F"]] $aRet = _ArrConcat_Max2D($aRet, $a2, 1) _ArrayDisplay($aRet) Func _ArrConcat_Max2D($aTarget, $aSource, $iLayout = 0) If Not IsArray($aTarget) Then Local $aTemp[1] = [$aTarget] $aTarget = $aTemp EndIf Local $iTgtD = Ubound($aTarget, 0) If $iTgtD > 2 Then Return SetError(1) If Not IsArray($aSource) Then Local $aTemp[1] = [$aSource] $aSource = $aTemp EndIf Local $iSrcD = Ubound($aSource, 0) If $iSrcD > 2 Then Return SetError(2) Local $a = UBound($aTarget), $b = $iTgtD = 1 ? 1 : UBound($aTarget, 2), _ $c = UBound($aSource), $d = $iSrcD = 1 ? 1 : UBound($aSource, 2) ; Determine the dimensions of the new array If $iLayout Then Local $aNew[($a > $c ? $a : $c)][$b + $d] Else Local $aNew[$a + $c][($b > $d ? $b : $d)] EndIf ; Add the contents of $aTarget If $iTgtD = 2 Then For $i = 0 To $a -1 For $j = 0 To $b -1 $aNew[$i][$j] = $aTarget[$i][$j] Next Next Else For $i = 0 To $a -1 $aNew[$i][0] = $aTarget[$i] Next EndIf ; Concatenate $aSource If $iLayout Then If $iSrcD = 2 Then For $i = 0 To $c -1 For $j = $b To $b + $d - 1 $aNew[$i][$j] = $aSource[$i][$j - $b] Next Next Else For $i = 0 To $c -1 $aNew[$i][$b] = $aSource[$i] Next EndIf Else If $iSrcD = 2 Then For $i = $a To $a + $c -1 For $j = 0 To $d - 1 $aNew[$i][$j] = $aSource[$i - $a][$j] Next Next Else For $i = $a To $a + $c - 1 $aNew[$i][0] = $aSource[$i - $a] Next EndIf EndIf Return $aNew EndFunc ; ==> _ArrConcat_Max2DAccepts any variable types that are not arrays of greater than 2 dimensions. Success always returns a 2D array. Edited September 28, 2015 by czardas kcvinu 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kcvinu Posted September 28, 2015 Author Share Posted September 28, 2015 @czardas Great. Let me check Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
czardas Posted September 28, 2015 Share Posted September 28, 2015 (edited) I should have explained that the layout parameter has two values: zero (= default) and NOT zero. When the layout is not zero, the source data (or array) is concatenated to the right of the target data (or array) with additional columns, otherwise it appears below with rows added.#include <Array.au3> ; For _ArrayDisplay ; add cols (1D & 1D & 2D) Local $aC1 = ['H','W'], $aC2 = ['E','O'], $aC3 = [['L','L','O'],['R','L','D']] Local $aRet = _ArrConcat_Max2D($aC1, $aC2, 1) $aRet = _ArrConcat_Max2D($aRet, $aC3, 1) _ArrayDisplay($aRet) ; add rows (2D & 2D) Local $aR1 = [['H','E','L','L','O']], $aR2 = [['W','O','R','L','D','!']] $aRet = _ArrConcat_Max2D($aR1, $aR2) _ArrayDisplay($aRet) ; cols side by side (1D & 1D) Local $aC3 = ['H','E','L','L','O'], $aC4 = ['W','O','R','L','D'] $aRet = _ArrConcat_Max2D($aC3, $aC4, 1) _ArrayDisplay($aRet) Edited September 28, 2015 by czardas iamtheky 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
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