Fedora Linux Support Community & Resources Center
  #1  
Old 22nd June 2012, 02:46 PM
mmix Offline
Registered User
 
Join Date: Aug 2009
Posts: 1,134
linuxfirefox
7 lines of code, 3 minutes: Implement a programming language from scratch

interesting. is there anyone do this in another programming anguages?
http://matt.might.net/articles/imple...ming-language/

Quote:
#lang racket

; bring in the match library:
(require racket/match)

; eval matches on the type of expression:
(define (eval exp env) (match exp
[`(,f ,e) (apply (eval f env) (eval e env))]
[`(λ ,v . ,e) `(closure ,exp ,env)]
[(? symbol?) (cadr (assq exp env))]))

; apply destructures the function with a match too:
(define (apply f x) (match f
[`(closure (λ ,v . ,body) ,env)
(eval body (cons `(,v ,x) env))]))

; read in, parse and evaluate:
(display (eval (read) '())) (newline)
Reply With Quote
Reply

Tags
code, implement, language, lines, minutes, programming, scratch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
J programming language mmix Programming & Packaging 0 13th June 2012 11:48 AM
Programming language. The Mishanator Programming & Packaging 13 12th November 2010 01:27 PM
D Programming Language sarahsman Programming & Packaging 2 25th December 2009 03:21 AM
ADA programming language? esnc Programming & Packaging 1 18th February 2009 04:22 AM
Programming language deepfreeze Linux Chat 8 1st November 2005 08:20 PM


Current GMT-time: 11:23 (Monday, 20-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Batumi Instagram Photos - Bailesti Instagram Photos - Lieto