Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Add to this code.

Name: Anonymous 2009-03-29 3:03

Here's how this works: I post some starter code and you post code that extends it and adds functionality in some way. No trolling, dammit.

=============================================================

#!/usr/bin/python

# I'm using Fedora 9

# list of commands available to the user (add commands here
comm_list = [\
"exit",\
"help",\
"!?"
]

def print_help ():
        """
        print a list of available commands and what they do
        """
        print ('"exit"                  = exit the program')
        print ('"help" or "!?"          = print this help message')
        return
   
def cli_main ():
        """
        this function implements the program using a command line interface
        """
        command = ''

        while command != comm_list [0]:#exit
            command = raw_input (":> ")
            if command == comm_list [0]: # exit
                print ("Terminating...")
            elif command == comm_list [1] or command == comm_list [2]: # !? or help
                print_help ()
                        # elif command == comm_list [n]:
                        #       do stuff
                        # etc.
            else:
                print ("I don't know what you mean; try typing something I understand.")
                print ("Type \"!?\" or \"" + self.comm_list [2] + "\" for help.")
        return 0
cli_main ()

Name: Anonymous 2009-03-29 3:05

3 = 4 # Valid in Fortran I

Name: Anonymous 2009-03-29 3:22


typedef int (*COM_METHOD)(const char*, void*);

struct command
{
   char* name;
   COM_METHOD method;
   char* description;
};

Name: Anonymous 2009-03-29 3:45

2 + 2 = 5 -- Valid in Haskell

Name: Anonymous 2009-03-29 3:46

/**
* Method to rate a string
* Ratings are determined by how much their visual cues please the Stallman
*
* @param toRate the string to rate
* @return the integer rating of the string on an ascending scale; with lowest value zero
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>;.

public int stallmanRating(String toRate) {
  if(toRate==null) throw new InvalidArgumentException("This string is null, and therefore cannot please the Sussman!");
  int rating = 0;
  int index = 0;
  char[] stallman = {'f','r','e','e'};
  for(int i=0; i<toRate.length(); i++) {
    if(toRate.charAt(i)==stallman[index]) {
      index++;
    }
    if(index==stallman.length) {
      rating+=1;
      index=0;
    }
  }
  return rating;
}

Name: Anonymous 2009-03-29 3:47

>>5
My apologies.

/**
* Method to rate a string
* Ratings are determined by how much their visual cues please the Stallman
*
* @param toRate the string to rate
* @return the integer rating of the string on an ascending scale; with lowest value zero
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>;.

public int stallmanRating(String toRate) {
  if(toRate==null) throw new InvalidArgumentException("This string is null, and therefore cannot please the Stallman!");
  int rating = 0;
  int index = 0;
  char[] stallman = {'f','r','e','e'};
  for(int i=0; i<toRate.length(); i++) {
    if(toRate.charAt(i)==stallman[index]) {
      index++;
    }
    if(index==stallman.length) {
      rating+=1;
      index=0;
    }
  }
  return rating;
}

Name: Anonymous 2009-03-29 3:49

>>6
God damn it I should have actually tried compiling this first.

/**
* Method to rate a string
* Ratings are determined by how much their visual cues please the Stallman
*
* @param toRate the string to rate
* @return the integer rating of the string on an ascending scale; with lowest value zero
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>;.
**/

public int stallmanRating(String toRate) {
  if(toRate==null) throw new InvalidArgumentException("This string is null, and therefore cannot please the Stallman!");
  int rating = 0;
  int index = 0;
  char[] stallman = {'f','r','e','e'};
  for(int i=0; i<toRate.length(); i++) {
    if(toRate.charAt(i)==stallman[index]) {
      index++;
    }
    if(index==stallman.length) {
      rating+=1;
      index=0;
    }
  }
  return rating;
}

Name: Anonymous 2009-03-29 3:53

fine, if you faggots can't tell the difference between /prog/ and /b/ then maybe I should ask moot to just delete /prog/

Name: Anonymous 2009-03-29 4:12

>>8
Maybe you should. But he'd probably tell you to fuck off like the faggot you are.

Name: Anonymous 2009-03-29 4:34

>>9
Well said, Anon.

Name: Anonymous 2009-03-29 6:17

No trolling, dammit.
How about using the godfuckingdamn code tag then‽‽‽

Don't change these.
Name: Email:
Entire Thread Thread List