Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Photo
- - - - -

Scheme And Lisp


8 replies to this topic

#1 loudthings

loudthings

    Newbie [ Level 1 ]

  • Members
  • 8 posts

Posted 09 February 2005 - 02:48 AM

I would like this topic to be a place where information about these two languages can be shared. LISP is a conceptual beautiful list based language. It is the language used to teach structure and interpretation of computer programs at UC Berkeley and is the language used to write the infamous chess-playing Deep Blue.

#2 loudthings

loudthings

    Newbie [ Level 1 ]

  • Members
  • 8 posts

Posted 09 February 2005 - 02:53 AM

I have implemented the basic Scheme primitive procedures as well as some of the most useful higher-order procedures in JavaScript. They are as follows: /* Scheme implementation in JavaScript
*/

function cons(e1, e2) {
return function(msg) {
if (msg == 0)
return e1;
else
return e2;
}
}

function car(aPair) {
return aPair(0);
}

function cdr(aPair) {
return aPair(1);
}

function list() {
var theList = cons(arguments[arguments.length - 1], null);
var c = 2;
while (c <= arguments.length) {
theList = cons(arguments[arguments.length - c], theList);
++c;
}
return theList;
}

function length(lst) {
var c = 0;
while (lst != null) {
lst = cdr(lst);
++c;
}
return c;
}

function item(pos, lst) {
var c = pos;
while (c != 0) {
lst = cdr(lst);
--c;
}
return car(lst);
}

function append(lst1, lst2) {
var c = length(lst1) - 1;
while (c >= 0) {
lst2 = cons(item(c, lst1), lst2);
--c;
}
return lst2;
}

function map(func, lst) {
var c = length(lst) - 1;
theList = cons(func(item(c, lst)), null);
--c;
while (c >= 0) {
theList = cons(func(item(c, lst)), theList);
--c;
}
return theList;
}

function filter(pred, lst) {
var c = length(lst) - 1;
theList = null;
while (c >= 0) {
if (pred(item(c, lst)) != false)
theList = cons(item(c, lst), theList);
--c;
}
return theList;
}

function accumulate(func, initial, lst) {
if (lst == null)
return initial;
else
return func(car(lst), accumulate(func, initial, cdr(lst)));
}

function position(e, lst) {
if (e == car(lst))
return 0;
else
return 1 + position(e, cdr(lst));
}

function isAtom(x) {
return typeof x == "string" || typeof x == "number" || typeof x == "boolean";
}

function not(x) {
if (x == false)
return true;
else
return false;
}

function isPair(x) {
return not(isAtom(x));
}

function flatten(lst) {
if (lst == null)
return null;
else {
if (isPair(car(lst)))
return append(flatten(car(lst)), flatten(cdr(lst)));
else
return cons(car(lst), flatten(cdr(lst)));
}
}


I have tested all the procedures, though not thoroughly, and they appear to work. This allows Scheme to be easily used for interesting web programs. Please feel free to add to these, report bugs, and post fixes. Contact me at tberg@berkeley.edu

#3 loudthings

loudthings

    Newbie [ Level 1 ]

  • Members
  • 8 posts

Posted 09 February 2005 - 03:22 AM

I am writing, using the scheme implementation in JavaScript that I posted earlier, a program that is a performance artwork. It is based on the digital artwork Galapagoes. Yet instead of evolving images, it evolves poems using user preference as natural selection. And instead of being in a galary somewhere it will be posted on the web so that many users can access it. It works be generating six poems by randomly picking words from a word bank. These initial poems are pretty much incoherent. Then the user picks the two of these poems that he or she likes best (likely the most coherent of these six). then the program takes a sort of numerical dna that encode the positions of the words in the two poems in the word bank. These two dna sequences are combined and slightly mutated, in effect creating an offspring of the two that has traits of each. The reproduction process is sufficiently random and variably that many offspring can be produced that are all different, but all have traits of the parent poems. The two poems are reproduced six times to create six new poems, the next generation. Then the user picks two from this generation, and the process continues. As this goes on, with many different user's input, each picking up with the last generation created by the last user, a sort of evolution occurs in the poems. They get more and more coherent and more and more interesting. User input in preference is the element of natural selection in the evolution. I hope to have the work up on a website soon. Im still working on the php to be able to record the last generation, so a new user can pick up the process where the last left off. I will post the URL of the website as soon as it is running.

#4 miCRoSCoPiC^eaRthLinG

miCRoSCoPiC^eaRthLinG

    PsYcheDeLiC dR3aMeR

  • [MODERATOR]
  • 2,248 posts
  • Gender:Male
  • Location:Bangkok, Thailand
  • Interests:Photography, Magic Tricks, Numismatics & Philately to some extent, Being a nuisance in general (that's my favourite)
  • myCENTs:NEGATIVE[-21.50]

Posted 09 February 2005 - 02:42 PM

Hey nice post ;) Do you have the original Scheme or Lisp code or both ? If so, can you please post them here ??
Thanks

#5 loudthings

loudthings

    Newbie [ Level 1 ]

  • Members
  • 8 posts

Posted 13 February 2005 - 12:47 AM

Hey nice post :P Do you have the original Scheme or Lisp code or both ? If so, can you please post them here ??
Thanks

<{POST_SNAPBACK}>

thanks, man. which original code do you mean? for the implementation of the languages? i have a metalinguistic implementation of a scheme interpretter (i. e. written in scheme). or do you mean for my project? i will post both! let me go get them.

#6 miCRoSCoPiC^eaRthLinG

miCRoSCoPiC^eaRthLinG

    PsYcheDeLiC dR3aMeR

  • [MODERATOR]
  • 2,248 posts
  • Gender:Male
  • Location:Bangkok, Thailand
  • Interests:Photography, Magic Tricks, Numismatics & Philately to some extent, Being a nuisance in general (that's my favourite)
  • myCENTs:NEGATIVE[-21.50]

Posted 19 February 2005 - 04:57 PM

thanks, man. which original code do you mean? for the implementation of the languages? i have a metalinguistic implementation of a scheme interpretter (i. e. written in scheme). or do you mean for my project? i will post both! let me go get them.

<{POST_SNAPBACK}>


Kinda...I meant the scheme/lisp versions of this code... I'm trying to pick up a little of lisp mysqlf - and I know a fair bit of javascript - so if I you could possibly post the lisp code in here - I'll be able to compare the syntax and make life a little easier for myself :P Thanks all the same...

#7 overture

overture

    Premium Member

  • Members
  • 208 posts
  • Location:England
  • Interests:Web Design, Web Programming, Software Programming, Drawing, Digital Art :D

Posted 19 February 2005 - 05:17 PM

cool Loudthings. I am gonna be learning lisp in the future due to my college work. We have a new unit called Expert Systems (Artificial Intelligence) and were are supposed to be programming our own little AI program when we learn enough. It all seems very interesting to me.

#8 KazDoran

KazDoran

    Member [ Level 1 ]

  • Members
  • 49 posts

Posted 26 June 2006 - 12:55 PM

After finishing my AI project, and having used Scheme as the language in another AI-related project, here's my thoughts:

Both Scheme and LISP are very powerful languages, as they allow for simple manipulation of data by hiding most of type verification.

Both languages earn a thumbs-up for allowing easy definition of abstract data-types. LISP has the advantage to allow some degree of OO programming through it's implementation of classes. It also allows to define structures in their own manner, creating the constructor and accessors automatically, which is definitely a plus.

The "everything is a list" point of view of both these languages can be at any time very useful, or very annoying, but it's nothing going against these languages.

Scheme, at a first glance, looks like a simplified version of LISP, by using the "define" form for (nearly) every declaration, as opposed to LISP, which uses a different form for different data types: "defun", "defvar", "defconst", etc...

LISP has the advantage (to some, a disadvantage) of allowing the same name to be used for several data types. You can define a function called "x" and then assign a value to x, and still use the function.

As for debugging, I found Scheme simpler to debug than LISP using the default options (I used Dr. Scheme to code in Scheme and Allegro, connected to Emacs through Slime, to code in LISP). Scheme gives away a very graphical debug info, with arrows pointing to where a function was called, or conflicts between names and/or arguments, as LISP only splattered about the steps in plain text mode, most often showing info about the internal procedures it uses to run our higher level code.

My two cents on this! :(

#9 mitchellmckain

mitchellmckain

    Premium Member

  • [HOSTED]
  • 411 posts
  • Location:Salt Lake City, Utah
  • Interests:Physics, Computer Programing (OpenGL, C++, Win32), Education, Educational Software, Board Games (especially Go and Magic the Gathering), Programmable Computer Games (like Starcraft and Neverwinter Nights), Science Fiction and Fantasy, Japan.
  • myCENTs:31.63

Posted 08 August 2006 - 11:10 PM

I recently wrote an introduction to Emacs lisp for the tutorial section. I use emacs lisp all the time for quick calculations and to analyze charts of data which I download from the internet. My relativity and space simulator relspace accepts many data formats but I often found it necessary to calculate estimates for missing data on all kinds astronomical objects so they could be included in my program. Nothing beats emacs for a quick and easy way of accomplishing this if you just have a little knowledge of how to program in lisp.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users