<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>IPorsut</title>
	<atom:link href="http://iporsut.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://iporsut.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sat, 07 Nov 2009 14:50:34 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>th</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='iporsut.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/247bd03ec17648a239e1a19f19270601?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>IPorsut</title>
		<link>http://iporsut.wordpress.com</link>
	</image>
			<item>
		<title>I love BoydNop</title>
		<link>http://iporsut.wordpress.com/2009/11/07/i-love-boydnop/</link>
		<comments>http://iporsut.wordpress.com/2009/11/07/i-love-boydnop/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 14:50:34 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Away Far So]]></category>
		<category><![CDATA[บอย โกสิยพงษ์]]></category>
		<category><![CDATA[ยาก]]></category>
		<category><![CDATA[boyd]]></category>
		<category><![CDATA[boydnop]]></category>
		<category><![CDATA[Love Is]]></category>
		<category><![CDATA[nop]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=145</guid>
		<description><![CDATA[ตอนนี้พี่ บอย มีโปรเจ็คใหม่กับพี่นพ คือ อลบั้ม BoydNop
มีเพลงปล่อยมาให้ฟังแล้ว 3 เพลง มีเป็น MV แล้ว 2 เพลงคือ Away Far So  กับ ยาก
MV แบบว่ารวมญาติมากๆ มีคนที่เคยร่วมงานกับพี่บอย ทั้งสมัย Bakery และ Love Is มากมาย
เช่น Lipta, Stamp, โต๋ และได้ พลอย มาร่วมด้วย พร้อมเด็กน้อยลูกๆหลานๆ น่ารักมาก
ตอนนี้ก็รอเมื่อไหร่จะมีอลบั้มเต็มๆวางแผงหละครับ ไม่พลาดแน่นอน และก็รอคอนเสิร์ต ที่ต้องออกมาดีแน่ๆ


       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=145&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>ตอนนี้พี่ บอย มีโปรเจ็คใหม่กับพี่นพ คือ อลบั้ม BoydNop</p>
<p>มีเพลงปล่อยมาให้ฟังแล้ว 3 เพลง มีเป็น MV แล้ว 2 เพลงคือ Away Far So  กับ ยาก</p>
<p>MV แบบว่ารวมญาติมากๆ มีคนที่เคยร่วมงานกับพี่บอย ทั้งสมัย Bakery และ Love Is มากมาย</p>
<p>เช่น Lipta, Stamp, โต๋ และได้ พลอย มาร่วมด้วย พร้อมเด็กน้อยลูกๆหลานๆ น่ารักมาก</p>
<p>ตอนนี้ก็รอเมื่อไหร่จะมีอลบั้มเต็มๆวางแผงหละครับ ไม่พลาดแน่นอน และก็รอคอนเสิร์ต ที่ต้องออกมาดีแน่ๆ</p>
<p><span style="text-align:center; display: block;"><a href="http://iporsut.wordpress.com/2009/11/07/i-love-boydnop/"><img src="http://img.youtube.com/vi/1LOExrPg_B0/2.jpg" alt="" /></a></span></p>
<p><span style="text-align:center; display: block;"><a href="http://iporsut.wordpress.com/2009/11/07/i-love-boydnop/"><img src="http://img.youtube.com/vi/hclnVm_obZw/2.jpg" alt="" /></a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=145&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2009/11/07/i-love-boydnop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/1LOExrPg_B0/2.jpg" medium="image" />

		<media:content url="http://img.youtube.com/vi/hclnVm_obZw/2.jpg" medium="image" />
	</item>
		<item>
		<title>Validate Form ด้วย LiveValidation</title>
		<link>http://iporsut.wordpress.com/2009/10/30/validate-form-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-livevalidation/</link>
		<comments>http://iporsut.wordpress.com/2009/10/30/validate-form-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-livevalidation/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 08:19:18 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[LiveValidation]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=133</guid>
		<description><![CDATA[เวลาสร้างฟอร์มในหน้าเพจให้กรอกข้อมูลอะไรสักอย่าง เราจำเป็นต้องตรวจสอบความถูกต้องของข้อมูลว่าเป็นตามเงื่อนไข หรือ ได้รูปแบบของข้อมูลที่ถูกต้องหรือไม่ เช่นฟอร์มรับสมัคร ฟอร์มกรอกเนื้อหาบล็อก ปกติเราจะตรวจสอบข้อมูลตรงนี้หลักจากที่ซับมิทข้อมูลไปแล้ว ก็ไปใช้ภาษาฝั่งเซอเวอร์ตรวจสอบเช่น php ถ้าข้อมูลไม่ถูกต้องก็ให้ redirect กลับมาที่หน้าฟอร์มใหม่ แต่วิธีนี้ต้องมีการ request ข้อมูลไปก่อนแล้วต้องรอ response กลับมา ถ้ากรอกผิดหลายรอบก็ต้องมานั่งซับมิทใหม่หลายๆรอบ
เราเลยจะใช้ภาษาฝั่ง client อย่าง javascript มาช่วยตรวจสอบข้อมูลของฟอร์มก่อนที่จะซับมิทข้อมูลไป มี library หลายเจ้าที่ช่วยตรงนี้ ที่เอามาให้ดูคือ LiveValidation เป็น เป็น library เล็กๆ มี pattern วิธีใช้ง่ายๆ
ตัวอย่างเช่นจะตรวจสอบว่า text input ที่มี id ชื่อว่า username นี้ต้องมีข้อมูลถ้าไม่มีจะ ซับมิทไปไม่ได้ และขึ้นข้อความบอกว่าข้อมูลไม่ถูกต้องให้เขียน script แบบนี้
var username = new LiveValidation('username');
username.add( Validate.Presence );
จากโค้ด ให้สร้าง object ของ LiveValidation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=133&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>เวลาสร้างฟอร์มในหน้าเพจให้กรอกข้อมูลอะไรสักอย่าง เราจำเป็นต้องตรวจสอบความถูกต้องของข้อมูลว่าเป็นตามเงื่อนไข หรือ ได้รูปแบบของข้อมูลที่ถูกต้องหรือไม่ เช่นฟอร์มรับสมัคร ฟอร์มกรอกเนื้อหาบล็อก ปกติเราจะตรวจสอบข้อมูลตรงนี้หลักจากที่ซับมิทข้อมูลไปแล้ว ก็ไปใช้ภาษาฝั่งเซอเวอร์ตรวจสอบเช่น php ถ้าข้อมูลไม่ถูกต้องก็ให้ redirect กลับมาที่หน้าฟอร์มใหม่ แต่วิธีนี้ต้องมีการ request ข้อมูลไปก่อนแล้วต้องรอ response กลับมา ถ้ากรอกผิดหลายรอบก็ต้องมานั่งซับมิทใหม่หลายๆรอบ</p>
<p>เราเลยจะใช้ภาษาฝั่ง client อย่าง javascript มาช่วยตรวจสอบข้อมูลของฟอร์มก่อนที่จะซับมิทข้อมูลไป มี library หลายเจ้าที่ช่วยตรงนี้ ที่เอามาให้ดูคือ LiveValidation เป็น เป็น library เล็กๆ มี pattern วิธีใช้ง่ายๆ</p>
<p>ตัวอย่างเช่นจะตรวจสอบว่า text input ที่มี id ชื่อว่า username นี้ต้องมีข้อมูลถ้าไม่มีจะ ซับมิทไปไม่ได้ และขึ้นข้อความบอกว่าข้อมูลไม่ถูกต้องให้เขียน script แบบนี้</p>
<pre class="brush: jscript;">var username = new LiveValidation('username');
username.add( Validate.Presence );</pre>
<p>จากโค้ด ให้สร้าง object ของ LiveValidation โดยใส่ชื่อ id ของ field ที่จะ validate เป็นพารามิเตอร์ จากนั้นเราจะเพิ่ม เงื่อนไขการตรวจสอบโดยเรียก method add แล้วกำหนดเงื่อนไขโดยใช้ค่าจาก object Validate เช่่น Validate.Presence ตรวจสอบว่าต้องมีข้อมูลกรอกที่ text input นี้</p>
<p>อีกตัวอย่างเป็นการตรวจสอบว่าต้องใส่ข้อมูลในรูปแบบของ email</p>
<pre class="brush: jscript;">var email = new LiveValidation('email');
email.add( Validate.Email );
</pre>
<p>เมื่อเรากรอกข้อมูลถูกต้อง หรือ ไม่ถูกต้อง ตัว LiveValidation จะเพิ่มข้อความบอกไว้หลัง input field โดยครอบอยู่ใน tag span โดยมี class ต่างๆบอกว่าสถานะว่าเป็น valid หรือ invalid เราสามารถจัด style sheet ให้กับข้อความในสถานะต่างๆได้ class ที่บอกสถานะต่างๆมีดังนี้</p>
<ul>
<li>LV_validation_message &#8211; the class that is added to all validation messages</li>
<li>LV_valid &#8211; the class that is added to a valid message</li>
<li>LV_invalid &#8211; the class that is added to an invalid message</li>
<li>LV_valid_field &#8211; the class that is added to a valid field</li>
<li>LV_invalid_filed &#8211; the class that is added to an invalid field</li>
</ul>
<p>Reference : <a href="http://livevalidation.com/">http://livevalidation.com/</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=133&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2009/10/30/validate-form-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-livevalidation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Tail Recursion</title>
		<link>http://iporsut.wordpress.com/2009/02/10/tail-recursion/</link>
		<comments>http://iporsut.wordpress.com/2009/02/10/tail-recursion/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 18:13:54 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[tail]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=127</guid>
		<description><![CDATA[การทำงานของโปรแกรมโดยทั่วไปเวลาเรียก function นั้นจะมีการจำตำแหน่งที่เรียกเอาไว้แล้วกระโดดเข้าไปทำงานใน function เมื่อเจอคำสั่ง return ก็จะกระโดดกลับมา ดั้งนั้นถ้ามีการเขียนแบบ recursive ก็จะมีการสร้าง stack ของการ call function ซ้อนๆกันไว้ แล้วพอ return ก็จะย้อนกลับมาทีละ step นี่คือกรณีของ recursive แบบธรรมดาทั่วๆไป ซึ่งจะเห็นว่าจะต้องเสียเวลาในการกระโดดกลับมา
Tail Recusion นั้นจะช่วยลดการทำงานตรงนั้นได้โดยแทนที่จะรอให้ได้ผลลัพธ์เมื่อมีการย้อน กลับ ก็จะทำการเก็บผลลัพธ์ตั้งแต่การเรียก recursive function จนเมื่อถึง การ call ครั้งสุดท้ายก็จะเป็นการ return ผลลัพธ์ออกมาทันที ไม่ต้องย้อนกลับไปอีก
ตัวอย่าง ฟังก์ชัน หาความยาวของ list ถ้าเขียนแบบ recursive ธรรมดา ได้แบบนี้

mylength :: [a] -&#62; Int

mylength [] = 0
mylength (y:ys) =  1+mylength (ys)

จะเห็นว่าแบบนี้ terminate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=127&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>การทำงานของโปรแกรมโดยทั่วไปเวลาเรียก function นั้นจะมีการจำตำแหน่งที่เรียกเอาไว้แล้วกระโดดเข้าไปทำงานใน function เมื่อเจอคำสั่ง return ก็จะกระโดดกลับมา ดั้งนั้นถ้ามีการเขียนแบบ recursive ก็จะมีการสร้าง stack ของการ call function ซ้อนๆกันไว้ แล้วพอ return ก็จะย้อนกลับมาทีละ step นี่คือกรณีของ recursive แบบธรรมดาทั่วๆไป ซึ่งจะเห็นว่าจะต้องเสียเวลาในการกระโดดกลับมา</p>
<p>Tail Recusion นั้นจะช่วยลดการทำงานตรงนั้นได้โดยแทนที่จะรอให้ได้ผลลัพธ์เมื่อมีการย้อน กลับ ก็จะทำการเก็บผลลัพธ์ตั้งแต่การเรียก recursive function จนเมื่อถึง การ call ครั้งสุดท้ายก็จะเป็นการ return ผลลัพธ์ออกมาทันที ไม่ต้องย้อนกลับไปอีก</p>
<p>ตัวอย่าง ฟังก์ชัน หาความยาวของ list ถ้าเขียนแบบ recursive ธรรมดา ได้แบบนี้</p>
<pre class="brush: java;">
mylength :: [a] -&gt; Int

mylength [] = 0
mylength (y:ys) =  1+mylength (ys)
</pre>
<p>จะเห็นว่าแบบนี้ terminate function จะรับค่า empty list แล้ว return 0 ออกมา เมื่อมีการ recursive ก็จะเอา 1 ไปบวกไป แบบนี้จะเกิดการ call ไปจนสุด แล้วค่อยเอาค่า มาบวกกันทีหลังแบบนี้</p>
<pre class="brush: java;">
mylength &quot;abc&quot; -&gt; 1+mylength(&quot;bc&quot;)
                        -&gt; 1+1+mylength(&quot;c&quot;)
                        -&gt; 1+1+1+mylength(&quot;&quot;)
                        -&gt; 1+1+1+0
                        -&gt; 1+1+1
                        -&gt; 1+2
                        -&gt; 3
</pre>
<p>แต่ถ้าเขียนแบบ tail recursive เราจะเพิ่มตัว accumulator เข้ามา ตัว accumulator ก็คือ พารามิเตอร์ที่เก็บ ผลลัพธ์ในแต่ละ step ที่ทำการ recursive เมื่อ terminate ที่เป็นการ call ครั้งสุดท้ายเราจะ return ค่า accumulator ออกมาทันที</p>
<pre class="brush: java;">
mylength :: [a] -&gt; Int
mylength ys =  _mylength ys 0
_mylength [] n = n
_mylength (y:ys) n = _mylength ys (n+1)
</pre>
<p>ตัวอย่างนี้เราเขียน function _mylenth ขี้นมาเป็น tail recursion แล้วตัวfunction mylength ของเรา ก็ค่อย call _mylength โดยส่งค่า 0 เป็นค่าเริ่มต้นของ accumulator</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=127&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2009/02/10/tail-recursion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Unicode in Coldfusion</title>
		<link>http://iporsut.wordpress.com/2009/02/10/unicode-in-coldfusion/</link>
		<comments>http://iporsut.wordpress.com/2009/02/10/unicode-in-coldfusion/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 16:07:50 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf-8]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=121</guid>
		<description><![CDATA[เนื่องจากว่ามันมีให้เซตหลายๆแบบ หลายๆจุด จะใช้ทีลืมประจำ ก็blogไว้ซะหน่อย

เอาโค้ดนี้ ไปไว้ใน Application.cfc

&#60;cfscript&#62;
    SetEncoding(&#34;form&#34;,&#34;utf-8&#34;);
    SetEncoding(&#34;url&#34;,&#34;utf-8&#34;);
&#60;/cfscript&#62;

แบบนี้คือบอกว่าข้อมูลที่อยู่ใน scope form และ url ใช้ utf-8


        &#60;cfcontent type=&#34;text/html; charset=utf-8&#34;&#62;

โค้ดนี้บอกว่า template ที่เปิดเป็นไฟล์แบบ text/html และ ใช้ charset เป็น utf8
โดยโค้ดนี้ต้องอยู่ส่วนบนสุดของไฟล์


        &#60;cfprocessingdirective pageEncoding=&#34;utf-8&#34;&#62;

อันนี้ก็เอาไปวางได้ทุกๆ template ที่มีการติดต่อ db หรือว่ามี i/o กับ browser
ถ้าใช้กับ coldbox [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=121&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>เนื่องจากว่ามันมีให้เซตหลายๆแบบ หลายๆจุด จะใช้ทีลืมประจำ ก็blogไว้ซะหน่อย</p>
<ol>
<li>เอาโค้ดนี้ ไปไว้ใน Application.cfc
<pre class="brush: xml;">
&lt;cfscript&gt;
    SetEncoding(&quot;form&quot;,&quot;utf-8&quot;);
    SetEncoding(&quot;url&quot;,&quot;utf-8&quot;);
&lt;/cfscript&gt;
</pre>
<p>แบบนี้คือบอกว่าข้อมูลที่อยู่ใน scope form และ url ใช้ utf-8</li>
<li>
<pre class="brush: xml;">
        &lt;cfcontent type=&quot;text/html; charset=utf-8&quot;&gt;
</pre>
<p>โค้ดนี้บอกว่า template ที่เปิดเป็นไฟล์แบบ text/html และ ใช้ charset เป็น utf8<br />
โดยโค้ดนี้ต้องอยู่ส่วนบนสุดของไฟล์</li>
<li>
<pre class="brush: xml;">
        &lt;cfprocessingdirective pageEncoding=&quot;utf-8&quot;&gt;
</pre>
<p>อันนี้ก็เอาไปวางได้ทุกๆ template ที่มีการติดต่อ db หรือว่ามี i/o กับ browser<br />
ถ้าใช้กับ coldbox ก็สามารถ เอาไปว่างไว้ที่ Layout ที่เดียวได้เลย</p>
<p><span style="background-color:#ffffff;color:#cc0000;"></span></li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=121&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2009/02/10/unicode-in-coldfusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Tree In Haskell</title>
		<link>http://iporsut.wordpress.com/2009/01/27/tree-in-haskell/</link>
		<comments>http://iporsut.wordpress.com/2009/01/27/tree-in-haskell/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 18:26:12 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[maybe]]></category>
		<category><![CDATA[tree]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=115</guid>
		<description><![CDATA[ตอนนี้กำลัง ค่อยๆ ไล่อ่าน หนังสือ Real World Haskell ที่ร่วมกันเขียนโดย  Bryan O&#8217;Sullivan, Don Stewart, and John Goerzen
หนังสือตีพิมพ์เป็นเล่มขายแล้ว อยากซื้อเก็บเหมือนกัน แต่ก็ไม่เคยซื้อผ่าน amazon ไม่มีพวกบัตรเครติด อะไรเลย ก็เลยยังไม่ซื้อ
หนังสือเล่มนี้ มีให้อ่านออนไลน์ผ่านเว็บ http://book.realworldhaskell.org/ ที่จริง หนังสือเล่มนี้ก่อนตีพิมพ์ ผู้แต่งเขาก็เอาขึ้นเว็บ
ให้อ่าน และก็ให้ comment ในแต่ละ paragraph ได้ในระหว่างแต่ง เพราะฉนั้นถ้าเข้าไปอ่านจะเห็นว่าในแต่ละ paragraph จะมีลิ้ง
ให้ comment ได้
มาว่ากันตามหัวข้อ คือ เขียนโครงสร้างข้อมูลแบบ Tree ด้วย Haskell ซึ่งมันเป็นแบบฝึกหัดอยู่ที่บทที่ 3 ว่าให้สร้าง data type Tree
โดยให้มี variable constructor ตัวเดียว โดยใช้ data type Maybe a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=115&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>ตอนนี้กำลัง ค่อยๆ ไล่อ่าน หนังสือ <a href="http://book.realworldhaskell.org">Real World Haskell</a> ที่ร่วมกันเขียนโดย  Bryan O&#8217;Sullivan, Don Stewart, and John Goerzen<br />
หนังสือตีพิมพ์เป็นเล่มขายแล้ว อยากซื้อเก็บเหมือนกัน แต่ก็ไม่เคยซื้อผ่าน amazon ไม่มีพวกบัตรเครติด อะไรเลย ก็เลยยังไม่ซื้อ</p>
<p>หนังสือเล่มนี้ มีให้อ่านออนไลน์ผ่านเว็บ <a href="http://book.realworldhaskell.org/">http://book.realworldhaskell.org/</a> ที่จริง หนังสือเล่มนี้ก่อนตีพิมพ์ ผู้แต่งเขาก็เอาขึ้นเว็บ<br />
ให้อ่าน และก็ให้ comment ในแต่ละ paragraph ได้ในระหว่างแต่ง เพราะฉนั้นถ้าเข้าไปอ่านจะเห็นว่าในแต่ละ paragraph จะมีลิ้ง<br />
ให้ comment ได้</p>
<p>มาว่ากันตามหัวข้อ คือ เขียนโครงสร้างข้อมูลแบบ Tree ด้วย Haskell ซึ่งมันเป็นแบบฝึกหัดอยู่ที่บทที่ <a href="http://book.realworldhaskell.org/read/defining-types-streamlining-functions.html">3</a> ว่าให้สร้าง data type Tree<br />
โดยให้มี variable constructor ตัวเดียว โดยใช้ data type Maybe a เข้าช่วย นั่งทำอยู่นาน กว่าจะทำได้ แล้วก็ได้ออกมาแบบนี้</p>
<pre class="brush: java;">
data Tree  a = Node a (Maybe (Tree a)) (Maybe (Tree a))
                deriving (Show)
</pre>
<p>ถ้าแบบไม่ใช้ Maybe ตามตัวอย่างในหนังสือจะเป็นแบบนี้ ซึ่งจะมี variable constructor 2 ตัวโดย มี Empty อีกตัว</p>
<pre class="brush: java;">
data Tree  a = Node a (Tree a) (Tree a)
                      | Empty
                deriving (Show)
</pre>
<p>data type Tree ที่สร้างมาเป็น type แบบ Recursive types จะเห็นว่า pattern ของ variable constructor จะมี<br />
data type Tree อยู่ด้วย ตัวอย่างการเอาไปใช้งานแบบ ไม่ใช้ Maybe จะเป็นแบบนี้</p>
<pre class="brush: java;">
myTree = Node 10 Empty Empty
myTree2 = Node 10 (Node 20 Empty Empty) Empty
</pre>
<p>ส่วนแบบ Maybe เราไม่จำเป็นต้อง สร้าง Empty ขึ้นมาเพราะเราจะใช้ Nothing ซึ่งเป็น ข้อมูลแบบ Maybe ในการกำหนดค่า<br />
childNode ของ Tree ได้ เช่น</p>
<pre class="brush: java;">
myTree = Node 10 Nothing Nothing
</pre>
<p>และ ใช้ Just ในการกำหนด childNode ที่ไม่เป็น Nothing</p>
<pre class="brush: java;">
myTree2 = Node 10 (Just (Node 20 Nothing Nothing)) Nothing
</pre>
<p>จบแค่นี้ครับ ไม่ได้อัพบล็อคตัวเองซะนาน เพราะหัวข้ออื่นๆก็เอาไปอัพที่ *66.com ซะหมดแล้ว</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=115&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2009/01/27/tree-in-haskell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Coldfusion cfloop readline from file</title>
		<link>http://iporsut.wordpress.com/2008/08/25/coldfusion-cfloop-readline-from-file/</link>
		<comments>http://iporsut.wordpress.com/2008/08/25/coldfusion-cfloop-readline-from-file/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 08:06:14 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[cfloop]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[readline]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=108</guid>
		<description><![CDATA[ตอนแรกตั้งใจอ่านไฟล์ โดยใช้ cffile ปกติ แล้วค่อยมาวนลูปค่าในไฟล์ที่ละบรรทัด
แล้วค้นไปเจอว่า CF8 มันสามารถใช้ cfloop กับ file ได้เลยลองใช้ดู ง่ายดีจริงๆ
ตัวอย่างเช่น

&#60;cfloop file=&#34;#Expandpath('nqi/cfcservice/')#data.txt&#34; index=&#34;line&#34;&#62;
    &#60;cfscript&#62;
        data = listtoarray(line,&#34;&#124;&#34;);
    &#60;/cfscript&#62;
    &#60;cfquery datasource=&#34;AisNQG&#34;&#62;
        insert into nqi_presentation values
        (&#60;cfqueryparam cfsqltype=&#34;cf_sql_date&#34; value=&#34;#data[1]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_varchar&#34; value=&#34;#data[2]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_varchar&#34; value=&#34;#data[3]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_varchar&#34; value=&#34;#data[4]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_varchar&#34; value=&#34;#data[5]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_varchar&#34; value=&#34;#data[6]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_numeric&#34; value=&#34;#data[7]#&#34;&#62;,
         &#60;cfqueryparam cfsqltype=&#34;cf_sql_numeric&#34; value=&#34;#data[8]#&#34;&#62;
         )
    &#60;/cfquery&#62;
&#60;/cfloop&#62;

แค่ใส่ attribute file เป็นพาธของไฟล์ ที่จะอ่าน แล้ว ใส่ตัวแปรให้กับ attribute index 
โดย เช่น line โดยตัวแปรนี้จะเก็บข้อมูลของแต่ละบรรทัดในไฟล์ที่กำลังอ่าน
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=108&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>ตอนแรกตั้งใจอ่านไฟล์ โดยใช้ cffile ปกติ แล้วค่อยมาวนลูปค่าในไฟล์ที่ละบรรทัด<br />
แล้วค้นไปเจอว่า CF8 มันสามารถใช้ cfloop กับ file ได้เลยลองใช้ดู ง่ายดีจริงๆ<br />
ตัวอย่างเช่น</p>
<pre class="brush: xml;">
&lt;cfloop file=&quot;#Expandpath('nqi/cfcservice/')#data.txt&quot; index=&quot;line&quot;&gt;
    &lt;cfscript&gt;
        data = listtoarray(line,&quot;|&quot;);
    &lt;/cfscript&gt;
    &lt;cfquery datasource=&quot;AisNQG&quot;&gt;
        insert into nqi_presentation values
        (&lt;cfqueryparam cfsqltype=&quot;cf_sql_date&quot; value=&quot;#data[1]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;#data[2]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;#data[3]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;#data[4]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;#data[5]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;#data[6]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_numeric&quot; value=&quot;#data[7]#&quot;&gt;,
         &lt;cfqueryparam cfsqltype=&quot;cf_sql_numeric&quot; value=&quot;#data[8]#&quot;&gt;
         )
    &lt;/cfquery&gt;
&lt;/cfloop&gt;
</pre>
<p>แค่ใส่ attribute file เป็นพาธของไฟล์ ที่จะอ่าน แล้ว ใส่ตัวแปรให้กับ attribute index <br />
โดย เช่น line โดยตัวแปรนี้จะเก็บข้อมูลของแต่ละบรรทัดในไฟล์ที่กำลังอ่าน</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iporsut.wordpress.com/108/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iporsut.wordpress.com/108/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=108&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2008/08/25/coldfusion-cfloop-readline-from-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple List Functions</title>
		<link>http://iporsut.wordpress.com/2008/08/22/simple-list-functions/</link>
		<comments>http://iporsut.wordpress.com/2008/08/22/simple-list-functions/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 02:42:58 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[list]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=54</guid>
		<description><![CDATA[ส่วนใหญ่แล้วการคำนวณต่างๆใน haskell programs คือการประมวลผล list ซึ่งมี 3 ฟังก์ชันหลักที่ทำหน้าที่ประมวลผลเกี่ยวกับ list คือ map, filter, foldr(รวมทั้ง foldl ด้วย)
map ฟังก์ชัน จะรับอาร์กิวเม้นคือ list และ ฟังก์ชันที่จะกระทำกับข้อมูลแต่ละตัวในลิสต์ที่รับเข้ามา เช่น ฟังก์ชัน Char.toUpper ที่รับค่า Char หนึ่งตัวแล้วเปลี่ยนให้เป็น Char ตัวใหญ่ทั้งหมด ดังนั้นถ้าเราต้องการเปลี่ยน character ทั้งหมดในสตริงให้เป็น ตัวใหญ่ ซึ่ง string ก็คือลิสต์ที่มีสมาชิกเป็น character เราสามารถ map ฟังก์ชัน toUpper ให้ทำงานกับทุกๆสมาชิกของ string ได้โดยใช้ฟังก์ชัน map ตัวอย่างการใช้งานเช่น

Prelude&#62; map Char.toUpper &#8220;Hello World&#8221;
&#8220;HELLO WORLD&#8221;
ใน การ ลบ ข้อมูลออกจากลิสต์ สามารถใช้ฟังก์ชัน filter [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=54&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>ส่วนใหญ่แล้วการคำนวณต่างๆใน haskell programs คือการประมวลผล list ซึ่งมี 3 ฟังก์ชันหลักที่ทำหน้าที่ประมวลผลเกี่ยวกับ list คือ map, filter, foldr(รวมทั้ง foldl ด้วย)</p>
<p>map ฟังก์ชัน จะรับอาร์กิวเม้นคือ list และ ฟังก์ชันที่จะกระทำกับข้อมูลแต่ละตัวในลิสต์ที่รับเข้ามา เช่น ฟังก์ชัน Char.toUpper ที่รับค่า Char หนึ่งตัวแล้วเปลี่ยนให้เป็น Char ตัวใหญ่ทั้งหมด ดังนั้นถ้าเราต้องการเปลี่ยน character ทั้งหมดในสตริงให้เป็น ตัวใหญ่ ซึ่ง string ก็คือลิสต์ที่มีสมาชิกเป็น character เราสามารถ map ฟังก์ชัน toUpper ให้ทำงานกับทุกๆสมาชิกของ string ได้โดยใช้ฟังก์ชัน map ตัวอย่างการใช้งานเช่น</p>
<p><span id="more-54"></span></p>
<p>Prelude&gt; map Char.toUpper &#8220;Hello World&#8221;<br />
&#8220;HELLO WORLD&#8221;</p>
<p>ใน การ ลบ ข้อมูลออกจากลิสต์ สามารถใช้ฟังก์ชัน filter ช่วยได้ ฟังก์ชันนี้ช่วยให้สามารถลบข้อมูลออกจากลิสต์โดยกำหนดเงื่อนไขที่ขึ้นอยู่ กับค่าของข้อมูลได้ ตัวอย่างเช่น ฟังก์ชัน Char.isLower จะบอกว่าข้อมูลเป็น character ตัวเล็กหรือไม่ เราสามารถใช้ filter ในการลบcharacterที่ไม่ได้เป็นอักษรตัวเล็กออกจากlistได้โดยทำดังนี้</p>
<p>Prelude&gt; filter Char.isLower &#8220;Hello World&#8221;<br />
&#8220;elloorld&#8221;</p>
<p>ฟังก์ชัน foldr รับค่าอาร์กิวเม้น 3 ค่า คือรับ ฟังก์ชัน,ค่าเริ่มต้น และ ลิสต์ จะเข้าใจ foldr ได้ง่ายๆคือมองลิสต์ที่รับเข้ามาในรูปของ cons operater เมื่อfoldr ทำงานจะเอา ฟังก์ชัน ไปแทนที่ : และเอาค่าเริ่มต้นไปแทน [] ดังนั้นถ้าเรามีลิสต์แบบนี้<br />
3:8:12:5:[]<br />
แล้วเราใช้foldr ดังนี้<br />
foldr (+) 0 [3,8,12,5] มันจะแปลงให้อยู่ในรูปแบบดังนี้<br />
3 + 8 + 12 + 5 + 0<br />
นั่นก็คือการเอาค่าใน list มาบวกกันลองใช้งานดูแบบนี้</p>
<p>Prelude&gt; foldr (+) 0 [3,8,12,5]<br />
28</p>
<p>ลองเปลี่ยนจาก (+) เป็น (*) และเปลี่ยนค่าเริ่มต้นเป็น 1 จะกลายเป็นการหาค่าผลคูณของทุกค่าในลิสต์</p>
<p>Prelude&gt; foldr (*) 1 [4,8,5]<br />
160</p>
<p>เมื่อ กี้บอกไปว่า foldr ทำงานโดยการแทนที่ : ด้วย function และ แทนที่ [] ด้วยค่าเริ่มต้น ที่นี้เกิดคำถามว่าแล้วกรณีที่ ฟังก์ชันที่รับเข้าไป ไม่เป็นแบบ associative ละ( associative คือ a*(b*c) = (a*b)*c ) เมื่อเราเขียน 4*8*5*1 เราหมายถึงเราเขียนวงเล็บแบบไหน แบบ ((4*8)*5)*1 หรือ 4*(8*(5*1)) foldr มองว่า functionที่รับเข้ามาเป็นแบบ right-associative ดังนั้นถ้าเราใช้ foldr กับ (-) จะได้ผลดังนี้</p>
<p>Prelude&gt; foldr (-) 1 [4,8,5]<br />
0</p>
<p>ขั้นตอนการทำงานของ foldr (-) 1 [4,8,5]<br />
foldr (-) 1 [4,8,5]<br />
==&gt;         4 &#8211; (foldr (-) 1 [8,5])<br />
==&gt;         4 &#8211; (8 &#8211; foldr (-) 1 [5])<br />
==&gt;         4 &#8211; (8 &#8211; (5 &#8211; foldr (-) 1 []))<br />
==&gt;         4 &#8211; (8 &#8211; (5 &#8211; 1))<br />
==&gt;         4 &#8211; (8 &#8211; 4)<br />
==&gt;         4 &#8211; 4<br />
==&gt;         0</p>
<p>ฟังก์ชัน foldl ทำงานเหมือน foldr ต่างกันตรงการวิธีการที่มันจะใส่วงเล็บ จากเมื่อกี้จะเห็นว่า foldr จะเป็น right-associative ส่วน foldl ก็คือ left-associative ตัวอย่างเช่น</p>
<p>Prelude&gt; foldl (+) 0 [3,8,12,5]<br />
28</p>
<p>Prelude&gt; foldl (-) 1 [4,8,5]<br />
-16<br />
จะเห็นว่าได้ผลต่างกับ foldr เพราะว่าวางวงเล็บคนละแบบ<br />
ขั้นตอนการทำงานของ foldl (-) 1 [4,8,5]<br />
foldl (-) 1 [4,8,5]<br />
==&gt;         foldl (-) (1 &#8211; 4) [8,5]<br />
==&gt;         foldl (-) ((1 &#8211; 4) &#8211; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> [5]<br />
==&gt;         foldl (-) (((1 &#8211; 4) &#8211; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &#8211; 5) []<br />
==&gt;         ((1 &#8211; 4) &#8211; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &#8211; 5<br />
==&gt;         ((-3) &#8211; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &#8211; 5<br />
==&gt;         (-11) &#8211; 5<br />
==&gt;          -16</p>
<p><strong>ข้อมูลอ้างอิง </strong></p>
<p>Yet Another Haskell Tutorial <a href="http://darcs.haskell.org/yaht/yaht.pdf">http://darcs.haskell.org/yaht/yaht.pdf</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iporsut.wordpress.com/54/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iporsut.wordpress.com/54/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=54&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2008/08/22/simple-list-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Strings in Haskell</title>
		<link>http://iporsut.wordpress.com/2008/08/22/strings-in-haskell/</link>
		<comments>http://iporsut.wordpress.com/2008/08/22/strings-in-haskell/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 02:42:03 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[string haskell]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=52</guid>
		<description><![CDATA[String ใน haskell ก็คือ list ของข้อมูลแบบ Chars นั่นเอง ดังนั้นเราจึงสามารถสร้าง string อย่างเช่น &#8220;hello&#8221; ได้แบบนี้
Prelude&#62; &#8216;H&#8217;:'e&#8217;:'l&#8217;:'l&#8217;:'o&#8217;:[]
&#8220;Hello&#8221;
List สามารถเชื่อมต่อกันได้ด้วย ++ string ก็ได้เช่นเดียวกันเพราะว่า string ก็คือ list ตัวอย่างเช่น

Prelude&#62; &#8220;Hello &#8221; ++ &#8220;World&#8221;
&#8220;Hello World&#8221;
สำหรับ ค่าข้อมูลที่ไม่ได้เป็นแบบ string สามารถถูกแปลงให้เป็น string ได้โดยใช้ ฟังก์ชัน show ส่วน string สามารถแปลงเป็นข้อมูลแบบอื่นได้ด้วยฟังก์ชัน read ถ้าเกิดค่าที่แปลงไม่ได้อยู่ในรูปแบบที่แปลงได้ก็จะเกิด error ขึ้น ตัวอย่างการใช้งานเช่น
Prelude&#62; &#8220;Five squared is &#8221; ++ show (5*5)
&#8220;Five squared is 25&#8243;
Prelude&#62; read &#8220;5&#8243; + [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=52&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>String ใน haskell ก็คือ list ของข้อมูลแบบ Chars นั่นเอง ดังนั้นเราจึงสามารถสร้าง string อย่างเช่น &#8220;hello&#8221; ได้แบบนี้</p>
<p>Prelude&gt; &#8216;H&#8217;:'e&#8217;:'l&#8217;:'l&#8217;:'o&#8217;:[]<br />
&#8220;Hello&#8221;</p>
<p>List สามารถเชื่อมต่อกันได้ด้วย ++ string ก็ได้เช่นเดียวกันเพราะว่า string ก็คือ list ตัวอย่างเช่น</p>
<p><span id="more-52"></span></p>
<p>Prelude&gt; &#8220;Hello &#8221; ++ &#8220;World&#8221;<br />
&#8220;Hello World&#8221;</p>
<p>สำหรับ ค่าข้อมูลที่ไม่ได้เป็นแบบ string สามารถถูกแปลงให้เป็น string ได้โดยใช้ ฟังก์ชัน show ส่วน string สามารถแปลงเป็นข้อมูลแบบอื่นได้ด้วยฟังก์ชัน read ถ้าเกิดค่าที่แปลงไม่ได้อยู่ในรูปแบบที่แปลงได้ก็จะเกิด error ขึ้น ตัวอย่างการใช้งานเช่น</p>
<p>Prelude&gt; &#8220;Five squared is &#8221; ++ show (5*5)<br />
&#8220;Five squared is 25&#8243;<br />
Prelude&gt; read &#8220;5&#8243; + 3<br />
8<br />
Prelude&gt; read &#8220;Hello&#8221; + 3<br />
Program error: Prelude.read: no parse</p>
<p>ข้อมูลอ้างอิง<br />
Yet Another Haskell Tutorial <a href="http://darcs.haskell.org/yaht/yaht.pdf">http://darcs.haskell.org/yaht/yaht.pdf</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iporsut.wordpress.com/52/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iporsut.wordpress.com/52/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=52&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2008/08/22/strings-in-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Lists</title>
		<link>http://iporsut.wordpress.com/2008/08/22/lists/</link>
		<comments>http://iporsut.wordpress.com/2008/08/22/lists/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 02:41:04 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[comprehensive]]></category>
		<category><![CDATA[list]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=50</guid>
		<description><![CDATA[ข้อจำกัดของ tuple ก็คือ จำนวนสมาชิกของข้อมูลที่เก็บจะมีจำนวนจำกัด ส่วนโครงสร้างแบบ list นั้นจะสามารถเพิ่มหรือลดจำนวนสมาชิกของข้อมูลได้ สร้าง list ใน haskell ได้ด้วยวิธีการคล้ายๆ tuple แต่เปลี่ยนจากวงเล็บแบบ () เป็น [] ตัวอย่างเช่น
Prelude&#62; [1,2]
[1,2]
Prelude&#62; [1,2,3]
[1,2,3]

list ยังอาจจะเป็นลิสต์ว่างก็ได้คือ [] คือไม่จำเป็นต้องมีสมาชิก เรียกว่า ลิสต์ว่าง หรือ empty list
ไม่ เหมือน tuple list สามารถเพิ่ม ข้อมูลเข้าไปที่ข้างหน้าได้โดยใช้ โคลอน(:) เรียกว่า cons โอเปอเรเตอร์ ที่มาของคำว่า cons ก็คือ &#8220;constructing a new list from an element and an old list&#8221; ก็คือการสร้างลิสต์ใหม่จาก สมาชิก และ ลิสต์เดิม [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=50&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>ข้อจำกัดของ tuple ก็คือ จำนวนสมาชิกของข้อมูลที่เก็บจะมีจำนวนจำกัด ส่วนโครงสร้างแบบ list นั้นจะสามารถเพิ่มหรือลดจำนวนสมาชิกของข้อมูลได้ สร้าง list ใน haskell ได้ด้วยวิธีการคล้ายๆ tuple แต่เปลี่ยนจากวงเล็บแบบ () เป็น [] ตัวอย่างเช่น</p>
<p>Prelude&gt; [1,2]<br />
[1,2]<br />
Prelude&gt; [1,2,3]<br />
[1,2,3]</p>
<p><span id="more-50"></span></p>
<p>list ยังอาจจะเป็นลิสต์ว่างก็ได้คือ [] คือไม่จำเป็นต้องมีสมาชิก เรียกว่า ลิสต์ว่าง หรือ empty list</p>
<p>ไม่ เหมือน tuple list สามารถเพิ่ม ข้อมูลเข้าไปที่ข้างหน้าได้โดยใช้ โคลอน(:) เรียกว่า cons โอเปอเรเตอร์ ที่มาของคำว่า cons ก็คือ &#8220;constructing a new list from an element and an old list&#8221; ก็คือการสร้างลิสต์ใหม่จาก สมาชิก และ ลิสต์เดิม ที่มีอยู่ ตัวอย่างการใช้ : ในการเพิ่มสมาชิกเข้าไปข้างหน้าลิสต์ เช่น</p>
<p>Prelude&gt; 0:[1,2]<br />
[0,1,2]<br />
Prelude&gt; 5:[1,2,3,4]<br />
[5,1,2,3,4]</p>
<p>เราอาจจะสามารถสร้างลิสต์จากได้ [] และ : ได้ เช่น<br />
Prelude&gt; 5:1:2:3:4:[]<br />
[5,1,2,3,4]</p>
<p>จริงๆ แล้วการสร้างลิสต์แบบ [5,1,2,3,4] เป็นรูปแบบไวยกรณ์ที่ง่ายๆ เพราะจริงๆแล้วเมื่อ compiler แปลงโปรแกรมจะทำการ แปลง ให้อยู่ในรูปของการใช้ : และ [] ในการเชื่อมข้อมูลแต่ละตัวในลิสต์</p>
<p>อีก ข้อแตกต่างนึงระหว่าง list และ tuple ก็คือ ข้อมูลที่มาเก็บใน list ต้องเป็นชนิดเดียวกันเท่านั้น ไม่สามารถเป็นคนละชนิดได้แบบ tuple</p>
<p>ลิสต์ สามารถเก็บสมาชิกได้หลายๆชนิดข้อมูล เช่นอาจจะเป็น ลิสต์ของจำนวนเต็ม ลิสต์ของสตริง ลิสต์ของลิสต์เอง หรือ ลิสต์ของtuple ก็ได้ ตัวอย่างเช่น</p>
<p>Prelude&gt; [(1,1), (2,4), (3,9), (4,16)]<br />
[(1,1), (2,4), (3,9), (4,16)]<br />
Prelude&gt; ([1,2,3,4], [5,6,7])<br />
([1,2,3,4], [5,6,7])</p>
<p>2 ฟังก์ชัน พื้นฐานที่ทำงานกับลิสต์คือ head และ tail ฟังก์ชัน head จะให้ผลลัพธ์เป็นสมาชิกตัวแรกของลิสต์ สำหรับอินพุตที่ไม่เป็นลิสต์ว่าง ส่วน tail จะให้ผลลัพธ์เป็นลิสต์ที่เหลือยกเว้นสมาชิกตัวแรก สำหรับอินพุตที่ไม่เป็นลิสต์ว่าง ตัวอย่างการใช้งานเช่น<br />
Prelude&gt; length [1,2,3,4,10]<br />
5<br />
Prelude&gt; head [1,2,3,4,10]<br />
1<br />
Prelude&gt; tail [1,2,3,4,10]<br />
[2,3,4,10]<br />
Prelude&gt; length (tail [1,2,3,4,10])<br />
4</p>
<p><strong>ข้อมูลอ้างอิงจาก</strong></p>
<p>Yet Another Haskell Tutorial <a href="http://darcs.haskell.org/yaht/yaht.pdf">http://darcs.haskell.org/yaht/yaht.pdf</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iporsut.wordpress.com/50/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iporsut.wordpress.com/50/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=50&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2008/08/22/lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
		<item>
		<title>Pairs, Triples, &#8230; Tuples</title>
		<link>http://iporsut.wordpress.com/2008/08/22/pairs-triples-tuples/</link>
		<comments>http://iporsut.wordpress.com/2008/08/22/pairs-triples-tuples/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 02:40:07 +0000</pubDate>
		<dc:creator>iporsut</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[pair]]></category>
		<category><![CDATA[triple]]></category>
		<category><![CDATA[tuple]]></category>

		<guid isPermaLink="false">http://iporsut.wordpress.com/?p=48</guid>
		<description><![CDATA[รูปแบบข้อมูลใน haskell นอกจากจะมาเป็นแบบค่าเดี่ยวๆแล้ว ยังมีข้อมูลแบบ pair ซึ่งก็คือข้อมูลแบบเป็นคู่ๆ เช่นข้อมูล pair ของจำนวนเต็ม สามารถสร้างได้โดยนำค่าใส่ใน วงเล็บ โดยมีคอมม่าคั่นข้อมูลคู่นั้น ลองใช้ pair ดูผ่าน ghci
 Prelude&#62; (4,9)
(4,9) นี่คือ pair ของเลข 4 และ 9 ใน haskell ค่าที่นำมาเป็นคู่ข้อมูล ไม่จำเป็นต้องเป็นชนิดข้อมูลแบบเดียวกัน เราสามารถสร้าง pair ของเลขจำนวนเต็ม คู่กับ string ได้ ซึ่งจะต่างกับ list ที่จำเป็นต้องมีข้อมูลชนิดเดียวกันทั้งหมด
มี ฟังก์ชัน 2 ฟังก์ชันที่ใช้สำหรับดึงค่า ข้อมูลตัวแรกของ pair และ ข้อมูลตัวที่สองของ pair นั่นคือ fst และ snd ตัวอย่างการใช้งานดังนี้

 Prelude&#62; fst (5, “hello”)
5
Prelude&#62; snd [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=48&subd=iporsut&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>รูปแบบข้อมูลใน haskell นอกจากจะมาเป็นแบบค่าเดี่ยวๆแล้ว ยังมีข้อมูลแบบ pair ซึ่งก็คือข้อมูลแบบเป็นคู่ๆ เช่นข้อมูล pair ของจำนวนเต็ม สามารถสร้างได้โดยนำค่าใส่ใน วงเล็บ โดยมีคอมม่าคั่นข้อมูลคู่นั้น ลองใช้ pair ดูผ่าน ghci<br />
<em> Prelude&gt; (4,9)<br />
(4,9) </em>นี่คือ pair ของเลข 4 และ 9 ใน haskell ค่าที่นำมาเป็นคู่ข้อมูล ไม่จำเป็นต้องเป็นชนิดข้อมูลแบบเดียวกัน เราสามารถสร้าง pair ของเลขจำนวนเต็ม คู่กับ string ได้ ซึ่งจะต่างกับ list ที่จำเป็นต้องมีข้อมูลชนิดเดียวกันทั้งหมด<br />
มี ฟังก์ชัน 2 ฟังก์ชันที่ใช้สำหรับดึงค่า ข้อมูลตัวแรกของ pair และ ข้อมูลตัวที่สองของ pair นั่นคือ fst และ snd ตัวอย่างการใช้งานดังนี้</p>
<p><span id="more-48"></span><br />
<em> Prelude&gt; fst (5, “hello”)<br />
5<br />
Prelude&gt; snd (5, “hello”)<br />
“hello”<br />
</em>นอกจากข้อมูลแบบเป็นคู่ pairs แล้วยังสามารถสร้างข้อมูลแบบ triples กลุ่มข้อมูล 3 ค่า และ quadruples กลุ่มข้อมูล 4 ค่า ตัวอย่าง triple และ quadruple เช่น<br />
<em> Prelude&gt; (1,2,3)<br />
(1,2,3)<br />
Prelude&gt; (1,2,3,4)<br />
(1,2,3,4)<br />
</em>โดยทั่วไปแล้วเราสามารถรวมกลุ่มข้อมูลกี่ค่าก็ได้อยู่ในวงเล็บแล้วคั่นด้วยคอมม่า ซึ่งเรียกรวมๆว่า tuples<br />
หมายเหตุ::  ฟังก์ชัน fst กับ snd สามารถใช้ได้แค่กับคู่ข้อมูล pair ได้เท่านั้น ไม่สามารถใช้กับ tuple ที่มีตั้งแต่ 3 ค่าได้<br />
<strong>exercise 3.2</strong> จงใช้ ฟังก์ชัน fst และ snd เพื่อดึงข้อมูลในแต่ละค่าที่เก็บอยู่ใน tuple นี้ ((1,&#8217;a'),”foo”)</p>
<p>&#8211; ดึงค่า 1<br />
Prelude&gt; fst ( fst ((1,&#8217;a'),”foo”) )<br />
1</p>
<p>&#8211; ดึงค่า &#8216;a&#8217;<br />
Prelude&gt; snd ( fst ((1,&#8217;a'),”foo”) )<br />
&#8216;a&#8217;</p>
<p>&#8211; ดึงค่า “foo”<br />
Prelude&gt; snd ( snd ((1,&#8217;a'),”foo”) )<br />
“foo”</p>
<p><strong><em>ข้อมูลอ้างอิงจาก</em></strong></p>
<p>Yet Another Haskell Tutorial <a href="http://darcs.haskell.org/yaht/yaht.pdf">http://darcs.haskell.org/yaht/yaht.pdf</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iporsut.wordpress.com/48/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iporsut.wordpress.com/48/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iporsut.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iporsut.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iporsut.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iporsut.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iporsut.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iporsut.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iporsut.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iporsut.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iporsut.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iporsut.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iporsut.wordpress.com&blog=1017193&post=48&subd=iporsut&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://iporsut.wordpress.com/2008/08/22/pairs-triples-tuples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57b0a5b2ed09861a60163f0703c60b4b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iporsut</media:title>
		</media:content>
	</item>
	</channel>
</rss>