<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Know Your Idioms</title>
	<atom:link href="http://www.hackinghat.com/index.php/programming/know-your-idioms/feed" rel="self" type="application/rss+xml" />
	<link>http://www.hackinghat.com/index.php/programming/know-your-idioms</link>
	<description></description>
	<lastBuildDate>Wed, 01 Feb 2012 14:27:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Steve Knight</title>
		<link>http://www.hackinghat.com/index.php/programming/know-your-idioms/comment-page-1#comment-8992</link>
		<dc:creator>Steve Knight</dc:creator>
		<pubDate>Sun, 29 Jun 2008 09:48:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackinghat.com/index.php/programming/know-your-idioms#comment-8992</guid>
		<description>Hi Eric,

Yeah, I found the family of functions that &#039;every&#039; belongs to as a result of Zak&#039;s response.   Hurrah for the web!  

But yes, if I understand you correctly, (null x) and (not (eq t x)) are not quite the same.   Since the second form does what I said I wanted whereas the first returns true for any non-nil value. 

Thanks for the LispCast stuff, by-the-way!

Steve</description>
		<content:encoded><![CDATA[<p>Hi Eric,</p>
<p>Yeah, I found the family of functions that &#8216;every&#8217; belongs to as a result of Zak&#8217;s response.   Hurrah for the web!  </p>
<p>But yes, if I understand you correctly, (null x) and (not (eq t x)) are not quite the same.   Since the second form does what I said I wanted whereas the first returns true for any non-nil value. </p>
<p>Thanks for the LispCast stuff, by-the-way!</p>
<p>Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Normand</title>
		<link>http://www.hackinghat.com/index.php/programming/know-your-idioms/comment-page-1#comment-8965</link>
		<dc:creator>Eric Normand</dc:creator>
		<pubDate>Tue, 24 Jun 2008 21:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackinghat.com/index.php/programming/know-your-idioms#comment-8965</guid>
		<description>It seems like you changed requirements halfway through.

At first you say this: 
&gt;return true if all the elements are T and nil if any are not T

Then you start counting (null x), not (not (eq t x)) 

Try this:

(every #&#039;(lambda (x) (eq t x)) list)</description>
		<content:encoded><![CDATA[<p>It seems like you changed requirements halfway through.</p>
<p>At first you say this:<br />
&gt;return true if all the elements are T and nil if any are not T</p>
<p>Then you start counting (null x), not (not (eq t x)) </p>
<p>Try this:</p>
<p>(every #&#8217;(lambda (x) (eq t x)) list)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Lyons</title>
		<link>http://www.hackinghat.com/index.php/programming/know-your-idioms/comment-page-1#comment-8961</link>
		<dc:creator>Daniel Lyons</dc:creator>
		<pubDate>Tue, 24 Jun 2008 16:19:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackinghat.com/index.php/programming/know-your-idioms#comment-8961</guid>
		<description>The smartass in me tried this:

(time (eval (cons &#039;and (loop for i below 1e6 collect t))))

But it blew up. And comparing it for 1e5 did not seem to show it being faster. Bummer. :)</description>
		<content:encoded><![CDATA[<p>The smartass in me tried this:</p>
<p>(time (eval (cons &#8216;and (loop for i below 1e6 collect t))))</p>
<p>But it blew up. And comparing it for 1e5 did not seem to show it being faster. Bummer. <img src='http://www.hackinghat.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zak</title>
		<link>http://www.hackinghat.com/index.php/programming/know-your-idioms/comment-page-1#comment-8077</link>
		<dc:creator>Zak</dc:creator>
		<pubDate>Fri, 18 Apr 2008 18:03:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackinghat.com/index.php/programming/know-your-idioms#comment-8077</guid>
		<description>&gt;(eq t x) is the same as x .

No, it isn&#039;t:

CL-USER&gt; (eq &#039;t 8)
NIL

You&#039;re right that identity is what I was looking for though.</description>
		<content:encoded><![CDATA[<p>&gt;(eq t x) is the same as x .</p>
<p>No, it isn&#8217;t:</p>
<p>CL-USER&gt; (eq &#8216;t <img src='http://www.hackinghat.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /><br />
NIL</p>
<p>You&#8217;re right that identity is what I was looking for though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: foo</title>
		<link>http://www.hackinghat.com/index.php/programming/know-your-idioms/comment-page-1#comment-8064</link>
		<dc:creator>foo</dc:creator>
		<pubDate>Fri, 18 Apr 2008 14:02:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackinghat.com/index.php/programming/know-your-idioms#comment-8064</guid>
		<description>(eq t x) is the same as x .

(loop for item in list always item)

(lambda (x) x) exists already. It is called IDENTITY.

(every #&#039;identity list)</description>
		<content:encoded><![CDATA[<p>(eq t x) is the same as x .</p>
<p>(loop for item in list always item)</p>
<p>(lambda (x) x) exists already. It is called IDENTITY.</p>
<p>(every #&#8217;identity list)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zak</title>
		<link>http://www.hackinghat.com/index.php/programming/know-your-idioms/comment-page-1#comment-8049</link>
		<dc:creator>Zak</dc:creator>
		<pubDate>Fri, 18 Apr 2008 08:47:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.hackinghat.com/index.php/programming/know-your-idioms#comment-8049</guid>
		<description>I tried notany and every on SBCL/linux-x86:

(notany #&#039;null &#039;(t t t t t t))
(every (lambda (x) x) &#039;(t t t t t t))

Both were slightly slower than the loop, but twice as fast as reduce. count-if and find-if were both a little slower than reduce.

Personally, I think notany is the clearest way to express this. Note also that not all of these forms are semantically equivalent: some test that all elements are the symbol &#039;t, and some test that none of the elements are nil. It is traditional Lisp style (and the behavior of CL&#039;s if) that any value that isn&#039;t nil is considered true, so if you&#039;re testing to see if a list of values are true it&#039;s probably best to use a form that does the latter.</description>
		<content:encoded><![CDATA[<p>I tried notany and every on SBCL/linux-x86:</p>
<p>(notany #&#8217;null &#8216;(t t t t t t))<br />
(every (lambda (x) x) &#8216;(t t t t t t))</p>
<p>Both were slightly slower than the loop, but twice as fast as reduce. count-if and find-if were both a little slower than reduce.</p>
<p>Personally, I think notany is the clearest way to express this. Note also that not all of these forms are semantically equivalent: some test that all elements are the symbol &#8216;t, and some test that none of the elements are nil. It is traditional Lisp style (and the behavior of CL&#8217;s if) that any value that isn&#8217;t nil is considered true, so if you&#8217;re testing to see if a list of values are true it&#8217;s probably best to use a form that does the latter.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

