<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: array flat]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=16239</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16239&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: array flat».]]></description>
		<lastBuildDate>Mon, 05 Apr 2021 21:21:27 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: array flat]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147178#p147178</link>
			<description><![CDATA[<p>Вот так с указанием уровня вложенности:<br /></p><div class="codebox"><pre><code>FlatArray(arr, depth := 0xFFFFFFFF) {
   if (depth = 0)
      Return arr
   Loop % len := arr.Count() {
      i := len - A_Index + 1
      if IsObject(arr[i])
         arr.InsertAt(i, FlatArray(arr.RemoveAt(i), depth - 1)*)
   }
   Return arr
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 05 Apr 2021 21:21:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147178#p147178</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: array flat]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147176#p147176</link>
			<description><![CDATA[<p>Если нужно раскрывать независимо от уровня вложенности, то так:<br /></p><div class="codebox"><pre><code>arr := [1, 2, [3, 4, [5, 6, [7, 8]]]]
arrayFlat(arr)
for k, v in arr
   str .= (str ? &quot;, &quot; : &quot;&quot;) . v
MsgBox, % str

arrayFlat(arr) {
   Loop % len := arr.Count() {
      i := len - A_Index + 1
      if IsObject(item := arr[i]) {
         arr.RemoveAt(i)
         arr.InsertAt(i, arrayFlat(item)*)
      }
   }
   Return arr
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 05 Apr 2021 19:30:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147176#p147176</guid>
		</item>
		<item>
			<title><![CDATA[AHK: array flat]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=147171#p147171</link>
			<description><![CDATA[<p>Пытаюсь сделать из массива:<br /></p><div class="codebox"><pre><code>[1, 2, [1, 3]]</code></pre></div><p>Массив:<br /></p><div class="codebox"><pre><code>[1, 2, 1, 3]</code></pre></div><p>Но что-то я подтупливаю:<br /></p><div class="codebox"><pre><code>arrayFlat(arr)
{
	newArr := []

	for i, v in arr
	{
		newArr.Push(IsObject(v) ? arrayFlat(v) : v)
	}

	return newArr
}</code></pre></div><p>UPD: Получилось что-то такое, как можно улучшить?<br /></p><div class="codebox"><pre><code>arrayFlat(arr, result := &quot;&quot;)
{
	if (!result)
	{
		result := []
	}

	for k, v in arr
	{
		if (isObject(v))
		{
			arrayFlat(v, result)
		}
		else
		{
			result.Push(v)
		}
	}

	return result
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Mon, 05 Apr 2021 15:28:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=147171#p147171</guid>
		</item>
	</channel>
</rss>
