Chingoon

From Applepedia

Jump to: navigation, search

http://www.chingoon.com

Missing languages: Algo, Lua, Fortran, Forth, ASM (68K, PPC)

Some of these implementations are needlessly complicated; it was intentional.

Contents

Compliance Levels

n-chin:

Must be able to produce the following image with a chin count of 2, and correspondingly taller chingoons with larger counts.

 __________
(--[ .]-[ .]
(       O  )
(          )
(__________)

1-chin:

Must produce the following image with a chin count of 1:

 __________
(--[ .]-[ .]
(       O  )
(__________)

0-chin:

Must produce the following image with a chin count of 0:

 __________
(--[ .]-[ .]
(_______O__)

Tcl

proc STgoon {} { return "  __________\n (--\[ .\]-\[ .\]\n (_______O__)" }
if {$n < 0} {set n 0}; if {$n > 7} {set n 7}; 
if {$n == 0} {return [STgoon]}; 
set lines [lines [STgoon]]; 
set chin [lindex $lines 2]; 
lremove lines 2; 
lappend lines [regsub -all _ $chin " "];
while {[incr n -1]} {lappend lines [regsub -all {[_O]} $chin " "]};
lappend lines [regsub -all O $chin _];
join $lines \n

Bourne shell

by minivanmegafun

#!/bin/sh 
CHINLIMIT=10
if [[ ! -n "$1"  ]]
then
    echo " ERROR: chingoon needs chins"
    exit 1
fi
if  [[ $1 -lt 0 ]]
then
    echo " ERROR: chingoon can't have a negachin"
    exit 1
fi
if [[ $1 -gt $CHINLIMIT ]]
then
    echo " ERROR: more chins than a chinese phone book and also more than \
    you'd really want to spam an IRC channel with you faggot (change \$CHINLIMIT)"
    exit 1
fi

echo " __________"
echo "(--[ .]-[ .]"
if [ ! $1 -eq 0 ]
then
    echo "(       O  )"
    for i in `jot $1`
    do
        echo "(          )"
    done
    echo "(__________)"
else
    echo "(_______O__)"
fi

Erlang

by bonzo

% bkerley@liam ~/Documents/smokeyrepo/chingoon> erl
% 1> c('chingoon').
% {ok,chingoon}
% 2> chingoon:chingoon(10).
% ok

-module (chingoon).
-export ([chingoon/1]).
-export ([chin_wrapper/1]).

line(Text) -> io:format(Text, []).

top(partial) ->
line(" __________~n"),
line("(--[ .]-[ .]~n");
top(full) ->
	top(partial),
	line("(       O  )~n").

chin_wrapper(Parent) ->
	chin(1),
	Parent!{chin}.

chin_spawner(0) ->
	0;
chin_spawner(Count) ->
	spawn(chingoon, chin_wrapper, [self()]),
	chin_spawner(Count - 1).

chin(0) -> 0;
chin(Count) ->
	line("(          )~n"),
	chin(Count - 1).

bottom() ->
	line("(__________)~n").

loop(1) ->
	bottom();
loop(Num) ->
	receive
		{chin} ->
			loop(Num - 1)
	end.

chingoon(0) ->
	top(partial),
	line("(_______O__)~n");
chingoon(Num) when is_integer(Num), Num >= 0 ->
	top(full),
	chin_spawner(Num - 1),
	loop(Num).

HyperTalk

by kalleboo

function chingoon number_of_chins
   if number_of_chins<0 then return "ERROR: chingoon can't have a negachin"
   else if number_of_chins>10 then return "ERROR: more chins than a chinese phone book and also more than you'd want to spam IRC with"
 
   put " __________" & return & "(--[ .]-[ .]" & return into chins
   if number_of_chins=0 then return chins & "(_______O__)"
   else put chins & "(       O  )" & return into chins
   
   repeat number_of_chins-1
      put chins & "(          )" & return into chins
   end repeat
  
   return chins & "(__________)"
end chingoon

AppleScript

by kalleboo

on chingoon(number_of_chins)
	if number_of_chins < 0 then
		return "ERROR: chingoon can't have a negachin"
	else
		if number_of_chins > 10 then return "ERROR: more chins than a chinese phone book and also more than you'd want to spam IRC with"
	end if
	
	copy " __________" & return & "(--[ .]-[ .]" & return to chins
	if number_of_chins = 0 then
		return chins & "(_______O__)"
	else
		copy chins & "(       O  )" & return to chins
	end if
	
	repeat number_of_chins-1 times
		copy chins & "(          )" & return to chins
	end repeat
	
	return chins & "(__________)"
end chingoon

Ruby

by will

#!/usr/bin/env ruby

if ARGV[0] !~ /^\d*$/ then
  raise SyntaxError, "Invalid Chins Argument"
end

chins = ARGV[0].to_i

puts <<DONGS
 __________
(--[ .]-[ .]
DONGS


case chins
when 0
  puts '(_______O__)'
else
  puts '(       O  )'
  (chins - 1).times do
    puts '(          )'
  end
  puts '(__________)'
end

Scheme

(define chins (round (max 0 (string->number (car (reverse (argv)))))))
(define (display-nl x) (display x) (newline))
(define (get-chins chins)
  (define head (list
                " __________"
                "(--[ .]-[ .]"
                ))
  (define fatty
    "(       O  )")
  (define slim
    "(_______O__)")
  (define middle
    "(          )")
  (define chin
    "(__________)")
  (append head
          (list (if (> chins 0) fatty slim))
          (let loop ((i 1) (face '()))
            (if (>= i chins) face
                (loop (+ i 1) (cons middle face))))
          (if (> chins 0) (list chin) '()) ))

(map  display-nl (get-chins chins))
(exit)

Perl

by mroach

#!/usr/bin/env perl

use strict;
use warnings;

my $chins = shift || 0;
my $scale = shift || 2;

my %components = (
    "scalp"         => { start => " ", repeat => "_", body => "________\n"  },
    "eyes"          => { start => "(", repeat => "-", body => "[ .]-[ .]\n" },
    "no_chin_mouth" => { start => "(", repeat => "_", body => "_____O__)"   },
    "chin_mouth"    => { start => "(", repeat => " ", body => "     O  )\n" },
    "chin_body"     => { start => "(", repeat => " ", body => "        )\n" },
    "chin_close"    => { start => "(", repeat => "_", body => "________)"   }
);

sub get_chin_component {
    my ($component_name) = @_;
    my $s = '';
    $s .= $components{$component_name}->{'start'};
    $s .= $components{$component_name}->{'repeat'} x $scale;
    $s .= $components{$component_name}->{'body'};
    return $s;
}

$chins = 0 unless $chins =~ m/^\d+$/;
$scale = 2 unless $scale =~ m/^\d+$/;
$scale = 2 unless $scale >= 1;

print &get_chin_component("scalp");
print &get_chin_component("eyes");

if ($chins == 0) {
  print &get_chin_component("no_chin_mouth");
  exit 0;
} else {
  print &get_chin_component("chin_mouth");
}

while (--$chins) {
  print &get_chin_component("chin_body");
}

print &get_chin_component("chin_close");

Condensed

#!/usr/bin/env perl
my $chins = shift || 0;
print " __________\n(--[ .]-[ .]\n";
if (!$chins) { print "(_______O__)\n"; exit 0 }
print "(       O  )\n";
while (--$chins) { print "(          )\n"; }
print "(__________)\n";

Java

by will

import java.lang.Integer;

public class ChinGoon {   
    public static void main(String[] args) throws Exception {
        int chins;   
        
        if(args.length == 0) {
            throw new Exception("Chins Not Provided"); }
        
        try {
            chins = Integer.parseInt(args[0]);
        } catch(NumberFormatException e) {
            throw new Exception("Invalid Chins Argument"); }
        
        System.out.println(" __________\n(--[ .]-[ .]");
        switch(chins) {
            case 0:
            System.out.println("(_______O__)");
            break;
            
            default:
            System.out.println("(       O  )");
                        
            for(int i = 0; i < chins - 1; ++i) {
                System.out.println("(          )"); }
                
            System.out.println("(__________)");
            break; }}}

C

#include "stdlib.h"
#include "stdio.h"
#define top_head " __________"
#define eyes     "(--[ .]-[ .]"
#define fatty    "(       O  )"
#define slim     "(_______O__)"
#define fat 	 "(          )"
#define chin     "(__________)"

void print_chin_goon(int chins) {
	int i = 0;
	puts(top_head);
	puts(eyes);
	if (chins > 0) {
		puts(fatty);
		for (i = 1 ; i < chins ; i++ ) {
			puts(fat);
		}
		puts(chin);
	} else if (chins <= 0) {
		puts(slim);
	}
}

int main(int argc, char ** argv) {
	int chins = 0;
	if (argc <= 1) {
		puts("Need an argument!");
		return 1;
	}
	chins = atoi(argv[1]);
	print_chin_goon(chins);
	return 0;	
}

Transact-SQL

by mroach

if (object_id('Chins', 'P') is not null)
	drop procedure dbo.Chins
go

create procedure dbo.Chins (@chins int)
as
begin
 	if (isnumeric(@chins) = 0)
		set @chins = 0

	if (@chins < 0)
		set @chins = 0

	print ' __________'
	print '(--[ .]-[ .]'

	if (@chins = 0)
	begin
		print '(_______O__)'
		return
	end
	else
		print '(       O  )'

	while (@chins > 1)
	begin
		print '(          )'
		set @chins = @chins - 1
	end

	print '(__________)'
end

Python

by minivanmegafun

#!/usr/bin/env python

import sys
try:
    chins = long(sys.argv[1])
except IndexError:
    raise IndexError, 'needachin'
except ValueError:
    raise ValueError, 'needintchins'

if chins < 0:
    raise ValueError, 'negachin'


print " __________"
print "(--[ .]-[ .]"

if chins == 0:
    print "(_______O__)"
    sys.exit(0)
else:
    print "(       O  )"
    for i in range(1, chins):
        print "(          )"
    print "(__________)"

VBScript (WScript)

by mroach

Option Explicit

Dim iChins

If WScript.Arguments.Count = 0 Then
    iChins = 0
Else
    iChins = WScript.Arguments.Item(0)
    If Not IsNumeric(iChins) Then iChins = 0
End If

WScript.Echo(" __________")
WScript.Echo("(--[ .]-[ .]")

If iChins = 0 Then
    WScript.Echo("(_______O__)")
    WScript.Quit
Else
    WScript.Echo("(       O  )")
    
    Do Until iChins = 1
        WScript.Echo("(          )")
        iChins = iChins - 1
    Loop
    
    WScript.Echo("(__________)")
End If

OCaml

let chin_goon chins =
  let  top_head  = " __________" in
  let  eyes      = "(--[ .]-[ .]" in
  let  fatty     = "(       O  )" in
  let  slim      = "(_______O__)" in
  let  fat       = "(          )" in
  let  chin      = "(__________)" in
  let rec gen_fat x l = 
    if (x <= 1) then l 
    else gen_fat (x - 1) (fat :: l) 
  in
    [ top_head ; eyes ] @ 
      (if (chins > 0) then
           (fatty :: (gen_fat chins [chin]))
       else
           [slim])
;;

let print_list l = List.iter print_endline l ;;

let run_chins chins =
  print_list (chin_goon chins)
;;

let last_of_array x = Array.get x ((Array.length x) - 1) ;;

run_chins (int_of_string (last_of_array Sys.argv));;

JavaScript

by sam

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <script type="text/javascript">
      var lines = [
        " __________", 
        "(--[ .]-[ .]",
        "(_______O__)",
        "(       O  )",
        "(          )",
        "(__________)"
      ];
      
      function drawChins() {
        var count  = parseInt(document.getElementById("count").value);
        var output = lines.slice(0, 2);
        if (count < 1) {
          output.push(lines[2]);
        } else {
          output.push(lines[3]);
          while (--count) output.push(lines[4]);
          output.push(lines[5]);
        }
        document.getElementById("output").innerHTML = output.join("\n");
      }
    </script>
  </head>
  <body>
    <form onsubmit="drawChins(); return false">
      <input id="count" type="text" value="0" />
      <input type="submit" />
    </form>
    <pre id="output"></pre>
  </body>
</html>

C#

by mroach

using System;
using System.Collections.Generic;
using System.Text;

namespace Chins {
    public struct FaceComponent {
        private string _start;
        private char _repeat;
        private string _body;

        public string Start { get { return _start; } }
        public char Repeat { get { return _repeat; } }
        public string Body { get { return _body; } }

        public FaceComponent(string start, char repeat, string body) {
            _start = start;
            _repeat = repeat;
            _body = body;
        }

        public string Construct(int scale) {
            string s = _start;
            s += String.Empty.PadLeft(scale, _repeat);
            s += _body;

            return s;
        }
    }

    public class FaceComponents {

        private int _scale;

        private FaceComponent _scalp;
        private FaceComponent _eyes;
        private FaceComponent _no_chin_close;
        private FaceComponent _multi_chin_mouth;
        private FaceComponent _chin;
        private FaceComponent _multi_chin_close;

        public string Scalp { get { return _scalp.Construct(_scale); } }
        public string Eyes { get { return _eyes.Construct(_scale); } }
        public string NoChinClose { get { return _no_chin_close.Construct(_scale); } }
        public string MultiChinMouth { get { return _multi_chin_mouth.Construct(_scale); } }
        public string Chin { get { return _chin.Construct(_scale); } }
        public string MultiChinClose { get { return _multi_chin_close.Construct(_scale); } }

        public FaceComponents(int scale) {
            InitializeComponents(scale);
        }

        public void InitializeComponents(int scale) {
            _scale = scale;

            _scalp = new FaceComponent(" ", '_', "________");
            _eyes = new FaceComponent("(", '-', "[ .]-[ .]");
            _no_chin_close = new FaceComponent("(", '_', "_____O__)");
            _multi_chin_mouth = new FaceComponent("(", ' ', "     O  )");
            _chin = new FaceComponent("(", ' ', "         )");
            _multi_chin_close = new FaceComponent("(", '_', "________)");
        }
    }

    class Program {
        static void Main(string[] args) {
            int chins = 0;
            int scale = 2;

            if (args.Length > 0)
                Int32.TryParse(args[0], out chins);

            if (args.Length > 1)
                Int32.TryParse(args[1], out scale);

            FaceComponents fc = new FaceComponents(scale);

            Console.WriteLine(fc.Scalp);
            Console.WriteLine(fc.Eyes);

            if (chins == 0) {
                Console.WriteLine(fc.NoChinClose);
                return;
            }
            else {
                Console.WriteLine(fc.MultiChinMouth);
                
                while (--chins > 0)
                    Console.WriteLine(fc.Chin);

                Console.WriteLine(fc.MultiChinClose);
            }
        }
    }
}

BASIC

by minivanmegafun

10 REM i feel like i'm 10 years old again
20 REM I don't have a clue how to handle command line parameters in BASIC,
30 REM so this is interactive.
40 INPUT "Number of Chins?";chins
50 REM I should be checking for an exception but for some reason I don't think
60 REM exception handling exists
70 PRINT " __________"
80 PRINT "(--[ .]-[ .]"
90 IF chins=0 THEN PRINT "(_______O__)" END ELSE PRINT "(       O  )"
150 FOR I=1 TO chins
170 PRINT "(          )"
180 NEXT I
190 PRINT "(__________)"
200 END

Postscript

by bonzo

% bkerley@liam ~/Documents/smokeyrepo/chingoon> echo 2 | gs -q chingoon.ps
%  __________
% (--[ .]-[ .]
% (       O  )
% (          )
% (__________)

/println {print (\n) print flush} def
/userread {(%stdin) (r) file 128 string readline} def
/top {( __________\n\(--[ .]-[ .]) println} def
/mouf {(\(       O  \)) println} def
/chin {(\(          \)) println} def
/bot {(\(__________\)) println} def
/spec {(\(_______O__\)) println} def

userread pop cvi
top
dup 0 eq
	{spec}
	{mouf
		1 sub {
			chin
		} repeat
		bot
	} ifelse
quit

PostScript that draws a page

by bonzo

% bkerley@liam ~/Documents/smokeyrepo/chingoon> (echo 4; cat) | gs -q -sDEVICE=x11alpha chingoon-page.ps
% >>showpage, press <return> to continue<<

/println {print (\n) print flush} def
/userread {(%stdin) (r) file 128 string readline} def
/pt {72 div} def
/y 9 def
/yd {y 14 pt sub /y exch def} def
/textdraw {/Courier findfont 12 pt scalefont setfont 8 pt y moveto show yd} def
/top {( __________) textdraw (\(--[ .]-[ .]) textdraw} def
/mouf {(\(       O  \)) textdraw} def
/chin {(\(          \)) textdraw} def
/bot {(\(__________\)) textdraw} def
/spec {(\(_______O__\)) textdraw} def

72 72 scale
0 0 0 setrgbcolor

userread pop cvi
top
dup 0 eq
	{spec}
	{mouf
		1 sub {
			chin
		} repeat
		bot
	} ifelse
showpage
quit

ColdFusion

by hodapp

<cfsetting enableCFoutputOnly = "Yes">

<cfset top_head = " __________
" >
<cfset eyes     = "(--[ .]-[ .]">
<cfset fatty    = "
(       O  )">
<cfset slim     = "
(_______O__)">
<cfset fat      = "
(          )">
<cfset chin     = "
(__________)">
		
<cfif isdefined('chins')>
	<cfset fat_factor = chins>
<cfelse>
	<cfset fat_factor = 0>
</cfif>
		
	<cfoutput><pre>#top_head#</cfoutput>
	<cfoutput>#eyes#</cfoutput>
		
<cfif fat_factor is "0">
	<cfoutput>#slim#</cfoutput>
		<cfabort>
<cfelse>
	<cfoutput>#fatty#</cfoutput>
</cfif>

<cfloop index="gummy_crunch" from="1" to="#fat_factor#">
	<cfif gummy_crunch is fat_factor>
		<cfoutput>#chin#</cfoutput>
	<cfelse>
		<cfoutput>#fat#</cfoutput>
	</cfif>
</cfloop>

	<cfoutput></pre></cfoutput>

Automator Workflow

by kalleboo

Image:Chingoon_workflow.png

LabView 8 Virtual Instrument

by zap

Image:chingoonfront.png Image:chingoonblock.png

Microsoft Excel

by kalleboo

Image:Chingoon_excel_2.png

bc - An arbitrary precision calculator language

define chins (x) {
    print " __________\n"
    print "(--[ .]-[ .]\n"
    if (x == 0) {
        print "(_______O__)\n"
    } else {
        print "(       O  )\n"
        if (x > 1) {
            for (i = 1; i < x; i++ ) {
                print "(          )\n"
            }
        }
        print "(__________)\n"
    }
}
chins(0)
chins(1)
chins(2)

awk

by minivanmegafun

#!/usr/bin/awk -f 

BEGIN{
    OFS="\n";
    numChins=int(ARGV[1]);
    # There's no real way to check if the user inputs a string, weo we're just
    # going to cast it as an int.  Awk just changes a string to zero.
    if(numChins < 0){
        print("fail");
        exit
    }
    scalp=" __________";
    eyes="(--[ .]-[ .]";
    mouth="(       O  )";
    chinFold="(          )";
    chinBot="(__________)";
    thinChin="(_______O__)"
    print(scalp,eyes);
    if(numChins == 0){
        print(thinChin);
        exit;
    }
    else{
        print(mouth);
    for(i=1; i<=numChins; i++){
        print(chinFold);
    }
    print chinBot;
    }
}

XSLT

by kalleboo

chingoon-definition.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="html.xsl"?>
<cgdl>
	<configuration>
			<chin />
			<chin />
	</configuration>
	<format>
		<head> __________
(--[ .]-[ .]</head>
		<fatty>(       O  )</fatty>
		<slim>(_______O__)</slim>
		<middle>(          )</middle>
		<chin>(__________)</chin>
	</format>
</cgdl>

html.xml

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/cgdl">

<xsl:variable name="num-chins" select="count(configuration/chin)" />

<xsl:variable name="head" select="format/head" />
<xsl:variable name="slim" select="format/slim" />
<xsl:variable name="fatty" select="format/fatty" />
<xsl:variable name="middle" select="format/middle" />
<xsl:variable name="chin" select="format/chin" />

<html>
<head>
	<title>Chingoon <xsl:value-of select="$num-chins" /></title>
</head>
<body>

<h1>Chingoon <xsl:value-of select="$num-chins" /></h1>

<pre>
<xsl:value-of select="$head" /><br />

<xsl:choose>
	<xsl:when test="$num-chins = 0">
		<xsl:value-of select="$slim" /><br />
	</xsl:when>
	<xsl:otherwise>
		<xsl:value-of select="$fatty" /><br />
		<xsl:for-each select="configuration/chin">
			<xsl:if test="position() != last()">
				<xsl:value-of select="$middle" /><br />
			</xsl:if>
		</xsl:for-each>
		<xsl:value-of select="$chin" />
	</xsl:otherwise>
</xsl:choose>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

Ada '95

by bleep

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;

procedure ChinGoon is
    Chincount : Integer := 0;
begin
    if Argument_Count = 1 then
        Chincount := Integer'Value(Argument(1));
    end if;

    Put_Line(" __________");
    Put_Line("(--[ .]-[ .]");
    if Chincount > 0 then
        Put_Line("(       O  )");
    end if;

    for I in 1..(Chincount - 1) loop
        Put_Line("(          )");
    end loop;

    if Chincount = 0 then
        Put_Line("(_______O__)");
    else
        Put_Line("(__________)");
    end if;
    
end ChinGoon;

Objective-C with Cocoa

by kalleboo

Download Chingoon.app.zip

Image:Chingoon.app.png

@interface Controller : NSObject {
    IBOutlet id chinSlider;
    IBOutlet id outputField;

- (IBAction)updateChins:(id)sender;

@end


@implementation Controller

- (NSString*)getChingoon:(int)chins {
	NSString* chinGoon = @" __________\n(--[ .]-[ .]\n";
	int i;
	
	if (chins == 0) {
		chinGoon = [chinGoon stringByAppendingString:@"(_______O__)\n"];
		return chinGoon;
	}
	
	chinGoon = [chinGoon stringByAppendingString:@"(       O  )\n"];
	
	for(i = 0; i < chins-1; i++) {
		chinGoon = [chinGoon stringByAppendingString:@"(          )\n"];
	}
	
	chinGoon = [chinGoon stringByAppendingString:@"(__________)\n"];
	
	return chinGoon;
}

- (IBAction)updateChins:(id)sender {	
	NSSlider *slider = (NSSlider*)sender;
	NSTextView *textView = (NSTextView*)outputField;
	
	[textView setString:[self getChingoon:[slider intValue]]];
}

@end

Quartz Composer

by kalleboo

<embed id="qt" src="http://stuff.gbsfm.info/Chingoon.mov" width="320" height="240" autoplay="true" loop="true" controller="false" pluginspage="http://www.apple.com/quicktime/"></embed>
  • Current failure since QC doesn't support recursion. Needs to be rewritten to work with graphics instead of strings. (build using accumulator and stepping chin height or something)
  • Chingoon.qtz.zip
  • Chingoon.mov

Image:Qc-3.png

Pascal

by mroach

program Chingoon( output );

function string_repeat (s: string; i: integer) : string;
begin
  var temp: string := '';

  while i > 0 do
  begin
    temp := temp + s;
    i := i - 1
  end;

  string_repeat := temp;
end;

begin
  var chins: integer := 0;
  var scale: integer := 2;
  if paramcount >= 1 then begin
    var conversion_result: integer;

    {Convert the chins arg to int and check the value}
    val(paramstr(1), chins, conversion_result);

    if conversion_result <> 0 then begin
      chins := 0;
    end;

    if chins < 0 then begin
      chins := 0;
    end;

    {If the scale arg is present, parse, set, check}
    if paramcount >= 2 then begin
      val(paramstr(2), scale, conversion_result);

      if conversion_result <> 0 then begin
        scale := 2;
      end;

      if scale < 2 then begin
        scale := 2;
      end;
    end;
  end;

  write(' '); write(string_repeat('_', scale)); writeln('________');
  write('('); write(string_repeat('-', scale)); writeln('[ .]-[ .]');

  {No chins}
  if chins = 0 then
  begin
    write('('); write(string_repeat('_', scale)); writeln('_____O__)');
    halt(0);
  end;

  {Some chins}
  write('('); write(string_repeat(' ', scale)); writeln('     O  )');

  while chins > 1 do
  begin
    chins := chins - 1;
    write('('); write(string_repeat(' ', scale)); writeln('        )');
  end;

  write('('); write(string_repeat('_', scale)); writeln('________)');
end.

Haskell

by kalleboo

>main = putStrLn (chingoon 2)

>chingoon :: Int -> String
>chingoon chincount = goonhead ++ mouth chincount ++ chins chincount ++ lastchin chincount

>mouth :: Int -> String
>mouth chincount 
>	| chincount == 0 = slim
>	| otherwise = fatty

>chins :: Int -> String
>chins chincount 
>	| chincount == 0 = ""
>	| chincount == 1 = ""
>	| otherwise = fatchin ++ chins (chincount-1)

>lastchin :: Int -> String
>lastchin chincount 
>	| chincount == 0 = ""
>	| otherwise = fatchinbot

>goonhead = " __________\n(--[ .]-[ .]\n"
>fatty = "(       O  )\n"
>slim = "(_______O__)\n"
>fatchin = "(          )\n"
>fatchinbot = "(__________)\n"

Windows Batch

by weasel

@echo off
set n=%1
echo  __________
echo (--[ .]-[ .]
if %n% equ 0 echo (_______O__) && goto ret
echo (       O  )
:chins
if %n% leq 1 goto end
echo (          )
set /a n=%n%-1
goto chins
:end
echo (__________)
:ret
Personal tools