• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

JavaScript Functional Pattern Matching ...

Adrien Friggeri has been playing with pattern matching in JavaScript a la functional programming.

Take a look at the examples such as writing a factorial via matching:
PLAIN TEXT
JAVASCRIPT:
function fact (n) {
  return m.match(n,
  [
    [    0  , function ( ) { return 1                    }],
    [ _("n"), function (a) { return (a.n * fact(a.n -1)) }]
  ]);
}
 

or working with complex structures:
PLAIN TEXT
JAVASCRIPT:
function go_deep(ob) {
  return m.match(ob,
  [
    [{foo:{bar:{baz:foo}}, baz:_()}, function (a) { return a.b  }],
    [_(\_)                             , function ( ) { return null }]
  ]);
}
 
source: ajaxian

 Original Source:

AddThis Social Bookmark Button

Posted at 01:14:52 pm | Permalink | Posted in Javascript  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

Top Stuff

e-messenger

MessengerFX

ILoveIM

eBuddy

Top 20 Ruby CMS

MSN Web Messenger



About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Search


Topics

  • .Net (138)
  • Ajax (50)
  • Ajax Games (10)
  • Articles (95)
  • Bookmarking (35)
  • Calendar (19)
  • Chat (42)
  • ColdFusion (3)
  • CSS (64)
  • Email (23)
  • Facebook (69)
  • Flash (18)
  • Google (44)
  • Html (23)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (47)
  • Javascript (231)
  • jQuery (79)
  • JSON (46)
  • Perl (2)
  • PHP (127)
  • Presentation (19)
  • Python (3)
  • Resources (2)
  • RSS (3)
  • Ruby (20)
  • Storage (4)
  • Toolkits (97)
  • Tutorials (214)
  • UI (11)
  • Utilities (173)
  • Web2.0 (18)
  • XmlHttpRequest (28)
  • YUI (5)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange