Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Blaze Advisor (SRL)

(AI-style language using Rete evaluation)

Date:10/10/07
Author:Patrick Cain
URL:n/a
Comments:0
Info:http://www.fairisaac.com/fic/en/product-service/product-index/blaze-advisor/
Score: (3.00 in 2 votes)
Create this Beer project:
Beer
+ Beer Folder
  + [->] BeerRuleset
         + v bottles : integer initially 99
         + v letsDrink : boolean initially false
         + v weNeedToShop : boolean initially false
         + v sing : boolean initially true
         + [->] singRule
                if sing then
                {
                  print(BottleText(bottles, true) " on the wall, " BottleText(bottles, false) ".");
                  sing is false;
                  letsDrink is (bottles is not equal to 0);
                  weNeedToShop is (bottles is 0);
                }
         
         + [->] shopRule
                if weNeedToShop then
                {
                  weNeedToShop is false;
                  bottles is 99;
                  print("Go to the store and buy some more..." BottleText(bottles, true) ".");
                }        
         + [->] drinkRule
                if letsDrink then
                {
                  letsDrink is false;
                  decrement bottles;
                  sing is true;
                  print("Take one down and pass it around..." BottleText(bottles, true) ".");
                  print("");
                }
  + f() BottleText(integer, boolean) : string
        Parameters:
          bottles : integer
          capitalise : boolean
        Function body:
          whatsInTheCrate is a string initially "" bottles;
          plural is a string initially "";
          if bottles is not equal to 1 then plural is "s";
          if bottles is 0 then
          {
            if capitalise then whatsInTheCrate is "No" else whatsInTheCrate is "no";
          }
          whatsInTheCrate is whatsInTheCrate " bottle" plural " of beer";
          return whatsInTheCrate;
  + f() main()
        Function body:
          apply BeerRuleset();


Key:
[->] Ruleset or rule
v    Variable
f()  Function

Download Source | Write Comment

Alternative Versions

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: