[plt-scheme] idiomatic way to split a list into first, middle, last?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jan 6 09:49:26 EST 2006

On Jan 6, 2006, at 8:47 AM, Bill Wood wrote:

> On Fri, 2006-01-06 at 08:05 -0500, Matthias Felleisen wrote:
>> Sorry I read your code backwards -- Matthias
> Not a problem.  I sometimes find Prolog code easier to understand if I
> turn around and read it through the back of my skull :-)
> You mentioned schelog in your initial response.  Are you suggesting 
> that
> it is a reasonable candidate for a rule-based pattern-matcher (which is
> what my original question was alluding to)?
>  -- Bill Wood

Dorai Sitaram's schelog is a full embedding of Prolog into Scheme.
It's based on my very first paper (tr) in Indiana; I must admit
Prolog was my second love, after Algol 60, and before Scheme.

See http://www.ccs.neu.edu/home/dorai/schelog/schelog.html
Download as is.
Ignore installation instructions.
Just cd into the directory and act as follows:

Welcome to MzScheme version 300.3, Copyright (c) 2004-2006 PLT Scheme 
 > (require (lib "defmacro.ss"))
 > (load "schelog.scm")
 > (%which () (%append '(1 2) '(3) '(1 2 3)))
 > (%which (done) (%append '(1 2) done '(1 2 3)))
((done (3)))

$append is the append relation. %which resolves goals. You can
go back and forth between Scheme and Prolog at your convenience.

Read manual (at above url) for more instructions. -- Matthias

Posted on the users mailing list.