<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Ближайшее к нулю число]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9542&amp;type=atom" />
	<updated>2014-04-27T17:47:56Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9542</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82361#p82361" />
			<content type="html"><![CDATA[<p>Точно. Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T17:47:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82361#p82361</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82360#p82360" />
			<content type="html"><![CDATA[<p>В таком разе проверку на знак числа поставить в первую очередь:<br /></p><div class="codebox"><pre><code>str = 0|500|400|200|
MsgBox % Min(str, &quot;-&quot;)
Min(str, s:= &quot;&quot;) { 
    Loop, Parse, str, &quot;|&quot;
        (s . 1) * A_LoopField &gt; 0 &amp;&amp; (!res || abs(res) &gt; abs(A_LoopField)) ? res := A_LoopField : &quot;&quot; 
   Return res
 }
 </code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2014-04-27T17:31:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82360#p82360</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82358#p82358" />
			<content type="html"><![CDATA[<p>Забыл уточнить, в строке ведь может не быть удовлетворяющего числа:<br /></p><div class="codebox"><pre><code>
str = 0|500|400|200|
</code></pre></div><p>Если тут надо отрицательное, то надо вернуть пустую строку.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T17:14:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82358#p82358</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82357#p82357" />
			<content type="html"><![CDATA[<p>Тоже качестве бреда сокращю-ка строчку.<br /></p><div class="codebox"><pre><code>
Min(str, s:= &quot;&quot;) { 
    Loop, Parse, str, &quot;|&quot;
        (!res || abs(res) &gt; abs(A_LoopField) &amp;&amp; (s . 1) * A_LoopField &gt; 0) ? res := A_LoopField : &quot;&quot; 
   Return res
 }
</code></pre></div><p><strong>Irbis</strong><br />Ну Вы меня второй день подряд радуете изысками <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T16:17:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82357#p82357</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82356#p82356" />
			<content type="html"><![CDATA[<p>На самом деле это было так, в порядке бреда <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />. А про флаг — такое условие было.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-04-27T16:10:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82356#p82356</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82355#p82355" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, ваш вариант красив, безусловно.<br />Правда, в моем примере в качестве флага &quot;s&quot; можно передавать не только &quot;-&quot;, но и &quot;+&quot;, а не только пустую строку для положительных числа, а в вашем Min(str, &quot;+&quot;) даст не тот ответ. Ну это мелочь.</p><div class="quotebox"><blockquote><p>serzh82saratov пишет:</p><p>Да кстати не ясно наличие оператора &quot;&gt;=&quot;, разве &quot;&gt;&quot; недостаточно?</p></blockquote></div><p>И это излишне, &quot;&gt;&quot; достаточно. Спасибо. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2014-04-27T16:07:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82355#p82355</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82354#p82354" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>но если уж возникла идея использовать Sort .</p></blockquote></div><p>Ну да, она первая и пришла.<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Да кстати не ясно наличие оператора &quot;&gt;=&quot;, разве &quot;&gt;&quot; недостаточно?</p></blockquote></div><p>Так всё таки.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T16:06:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82354#p82354</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82353#p82353" />
			<content type="html"><![CDATA[<p>Мой, конечно, по скорости не оптимальный, но если уж возникла идея использовать <em>Sort</em> <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-04-27T16:02:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82353#p82353</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82352#p82352" />
			<content type="html"><![CDATA[<p>Пожалуйста. <br />Ну, в общем, сначала была мысль ускорить обработку строки - из отсортированной строки выводить первое положительное число для случая с &quot;+&quot; числами. Потом отказался, т.к. сортировка априори занимает больше времени, чем однократный проход по всему ряду. Но тем не менее стоку с сортировкой забыл убрать. (*фейспалм*)</p><p>Для таких запущенных, как у меня, случаев, пытливый взгляд модератора как нельзя кстати. <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2014-04-27T15:58:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82352#p82352</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82351#p82351" />
			<content type="html"><![CDATA[<p>Мой вариант:<br /></p><div class="codebox"><pre><code>str = -345|-100|-234|0|500|400|200|
MsgBox % Min(str, &quot;-&quot;) . &quot;`n&quot; . Min(str)

Min(str, s:= &quot;&quot;)
{
   Sort, str, N D|
   Return RegExReplace(str, s ? &quot;.*(\-\d+).*&quot; : &quot;.*?\|([^\-0]\d+).*&quot;, &quot;$1&quot;)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-04-27T15:56:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82351#p82351</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82350#p82350" />
			<content type="html"><![CDATA[<p>Да кстати не ясно наличие оператора &quot;&gt;=&quot;, разве &quot;&gt;&quot; недостаточно?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T15:56:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82350#p82350</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82349#p82349" />
			<content type="html"><![CDATA[<p><strong>Irbis</strong>Благодарю за работу <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="quotebox"><blockquote><p>ТС упомянул про возможное отсутствие &quot;0&quot; в списке, чтобы не было повода решить задачу поиском следующего за нулем числа в отсортированной строке для положительных чисел (или предыдущего - для отрицательных).</p></blockquote></div><p>Мысли читаете <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="quotebox"><blockquote><p>М-м-м... А зачем тут вообще строчка</p></blockquote></div><p>Прямо как в недавней теме <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T15:47:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82349#p82349</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82348#p82348" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><p><strong>teadrinker</strong>, чем же вам &quot;0&quot; не угодил? Я так понимаю, ТС упомянул про возможное отсутствие &quot;0&quot; в списке, чтобы не было повода решить задачу поиском следующего за нулем числа в отсортированной строке для положительных чисел (или предыдущего - для отрицательных).</p><div class="codebox"><pre><code>str = -345|-100|-234|0|500|400|200|
Sort, str, N D|
MsgBox % Min(str, &quot;-&quot;)
Return
Min(str, s:= &quot;&quot;)
{
   Loop, Parse, str, &quot;|&quot;
      if !res || abs(res) &gt;= abs(A_LoopField) &amp;&amp; (s . 1) * A_LoopField &gt; 0
      res := A_LoopField
   Return res
}
</code></pre></div></blockquote></div><p>М-м-м... А зачем тут вообще строчка<br /></p><div class="codebox"><pre><code>Sort, str, N D|</code></pre></div><p>если всё равно сравниваются все числа подряд? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-04-27T15:36:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82348#p82348</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82347#p82347" />
			<content type="html"><![CDATA[<p>Да не знаю, просто уточнил, дабы не было желания искать в отсортированной строке ноль и число рядом с ним.<br /></p><div class="quotebox"><blockquote><p>Просто задача поставлена не совсем корректно.</p></blockquote></div><p>Даже не знаю как ещё сформулировать задачу... вроде всё просто.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-04-27T15:28:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82347#p82347</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ближайшее к нулю число]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=82346#p82346" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, чем же вам &quot;0&quot; не угодил? Я так понимаю, ТС упомянул про возможное отсутствие &quot;0&quot; в списке, чтобы не было повода решить задачу поиском следующего за нулем числа в отсортированной строке для положительных чисел (или предыдущего - для отрицательных).</p><div class="codebox"><pre><code>str = -345|-100|-234|0|500|400|200|
Sort, str, N D|
MsgBox % Min(str, &quot;-&quot;)
Return
Min(str, s:= &quot;&quot;)
{
   Loop, Parse, str, &quot;|&quot;
      if !res || abs(res) &gt;= abs(A_LoopField) &amp;&amp; (s . 1) * A_LoopField &gt; 0
      res := A_LoopField
   Return res
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2014-04-27T15:26:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=82346#p82346</id>
		</entry>
</feed>
