<?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/"
	>

<channel>
	<title>OpenCog Brainwave &#187; Development</title>
	<atom:link href="http://blog.opencog.org/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.opencog.org</link>
	<description>The latest developments in building an open-source mind</description>
	<lastBuildDate>Wed, 21 Mar 2012 16:44:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>scheme shell</title>
		<link>http://blog.opencog.org/2008/05/27/scheme-shell/</link>
		<comments>http://blog.opencog.org/2008/05/27/scheme-shell/#comments</comments>
		<pubDate>Tue, 27 May 2008 14:02:44 +0000</pubDate>
		<dc:creator>Linas Vepstas</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Guile]]></category>
		<category><![CDATA[OpenCog]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://opencog.wordpress.com/?p=21</guid>
		<description><![CDATA[I needed the ability to hand-edit opencog data while other processes were running. And so I hacked with guile for a while, and now there's a scheme shell for opencog.
So far it's very simple: just say 'scm' at the ...]]></description>
			<content:encoded><![CDATA[<p>I needed the ability to hand-edit opencog data while other processes were running. And so I hacked with guile for a while, and now there&#8217;s a scheme shell for opencog.<br />
So far it&#8217;s very simple: just say &#8216;scm&#8217; at the opencog prompt; this puts you into the shell. Then you can scheme away.</p>
<p>So, fore example:</p>
<p>&nbsp;&nbsp;<code>(cog-new-node 'ConceptNode "some node name")</code></p>
<p>creates a new node:</p>
<p>&nbsp;&nbsp;<code>#&lt;node[3:some node name] sti:(0,0) tv:(0.000000,0.000000)&gt;</code></p>
<p>Well&#8230; I suppose the above looks like goobldy-gook. But it just says that its a new node with zero &#8220;short-term importance&#8221; (sti) and zero &#8220;truth value&#8221; (tv). It would be slicker if all this could be viewed visually, as a graph&#8230; the above would be just a single point, with a label.</p>
<p>Creating links is easy:</p>
<p>&nbsp;&nbsp;<code>(define x (cog-new-node 'ConceptNode "abc"))<br />
(define y (cog-new-node 'ConceptNode "def"))<br />
(cog-new-link 'Link x y)</code></p>
<p>which creates two new nodes (called &#8216;x&#8217; and &#8216;y&#8217;) and a link connecting the two. Here&#8217;s the result:</p>
<p>&nbsp;&nbsp;<code>#&lt;link[2 sti:(0,0) tv:(0.000000,0.000000) &lt;[3 abc],[3 def]&gt;]&gt;</code></p>
<p>What&#8217;s slick about scheme is that it&#8217;s easy to add a bit of syntactic sugar to make link and node creation even easier. So, for example, we can define some new functions:</p>
<p>&nbsp;&nbsp;<code>(define (concept x) (cog-new-node 'ConceptNode x))<br />
    (define (pred x)    (cog-new-node 'PredicateNode x))<br />
    (define (listyl x)  (cog-new-link 'ListLink x)) ; list is a reserved word in scheme<br />
    (define (evely x)  (cog-new-link 'EvaluationLink x))  ; eval is a reserved word in scheme</code></p>
<p>and with this syntactic sugar:</p>
<p>&nbsp;&nbsp;<code>(evely  (pred "eats") (listyl (concept "cat") (concept "fish")))</code></p>
<p>which creates the opencog graph:</p>
<p>&nbsp;&nbsp;<code>#&lt;link[53 sti:(0,0) tv:(0.000000,0.000000) &lt;[47 eats],link[13 sti:(0,0) tv:(0.000000,0.000000) &lt;[3 cat],[3 fish]&gt;]&gt;]&gt;</code></p>
<p>So I&#8217;m thrilled. I can finally create, edit and delete nodes on the fly, without having to write C++ code, compile it, etc. etc.  Woo hoo!</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.opencog.org/?flattrss_redirect&amp;id=21&amp;md5=fbf004386d343161362442db104303ef" title="Flattr" target="_blank"><img src="http://blog.opencog.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.opencog.org/2008/05/27/scheme-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

