unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: stefan <stefan.tampe@spray.se>
To: guile-devel@gnu.org
Subject: unified field theory!
Date: Sun, 23 May 2010 16:52:42 +0200	[thread overview]
Message-ID: <201005231652.42280.stefan.tampe@spray.se> (raw)

Hi,

I)
I did introduce prompts to the example unify code, and the comparison 
resulted in
no-prompt     :  37ms
gp-prompt     :  35ms
guile-prompts :  49ms

I think using guile prompts are acceptable here. But they are on the expensive 
side, especially in the light that unwinding should not put a significan
mark on the timings.

II)
unify variables and fluid variables are close in nature. So it would be cool
to understand the difference better. i will dive in on that. 

III)
One cool thing is to abstract out matchers. As a result you get a little tool
to create top down parsers. here we go, consider

(udef <i> (((? integer? X) . L) (cons X  L)
	   (L                   (cons #f L))))

A matcher for an integer!

the output of a matcher has to be of the from (cons Val Rest). when Val 
equals #f it sends the signal of a failure. (perhaps use (values Val Rest) 
instead)

now we can use this as
(udef f ((<i> <i> 'a 'b) 'ok)) 

and 

(f '(1 2 a b)) will match to 'ok

But it's really nice to have arguments to the matcher so consider

(udef <...> ((F   (  (<> F)   (<...> F)  )  (cons (cons F.0 <...>.0) 
						  <...>...))
	     (F    L                        (cons '() L))))

F.0   is the value of the (<> F) match. F... is the rest of the same match and
so on. Now <...> is a gready matcher that has one argument F that itself is 
a matcher and now we can use it accordingly. if a symbol looks like <symb>
then it's a matcher abstraction. (<> F) is used when the matcher has a name
not of that form.

(udef f ((   (<...> <i>) . L)  L))

and

(f '(1 23 4 a b)) 

gives

'(a b)

Have fun,

Stefan







             reply	other threads:[~2010-05-23 14:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-23 14:52 stefan [this message]
2010-05-23 21:12 ` unified field theory! Andy Wingo
2010-05-25  8:06   ` stefan
2010-05-26 11:16   ` fluids and unification Stefan
2010-05-26 13:13     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201005231652.42280.stefan.tampe@spray.se \
    --to=stefan.tampe@spray.se \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).