Scalegoon

From Applepedia

Jump to: navigation, search

Contents

Scalegoon

2 Parameters fatiness and chins (both non-negative integers)

scalegoon 0 x == chingoon x


scalegoon 0 0

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

scalegoon 1 0

 ___________ 
(---[ .]-[ .]
(________O__)

scalegoon 10 0

 ____________________ 
(------------[ .]-[ .]
(_________________O__)

scalegoon 10 1

 ____________________ 
(------------[ .]-[ .]
(                 O  )
(____________________)

scalegoon 10 2

 ____________________ 
(------------[ .]-[ .]
(                 O  )
(                    )
(____________________)

scalegoon 5 5

 _______________
(-------[ .]-[ .]
(            O  )
(               )
(               )
(               )
(               )
(_______________)

Scheme

Chicken Scheme

(define args (reverse (argv)))
(define (parse-arg x) (max 0 (string->number x)))
(define chins (parse-arg (car args)))
(define fats  (parse-arg (cadr args)))

; (define chins (round (max 0 (string->number (car (reverse (argv)))))))

(define (display-nl x) (display x) (newline))
(define (get-scale-goon fatness chins)
  (define (fatify c) (make-string fatness (string-ref c 0)))
  (define head (list
                (string-append " __________" (fatify "_"))
                (string-append "(" (fatify "-")  "--[ .]-[ .]")
                ))
  (define fatty 
    (string-append "(" (fatify " ") "       O  )"))
  (define slim
    (string-append "(" (fatify "_") "_______O__)"))
  (define middle 
    (string-append "(" (fatify " ") "          )"))
  (define chin 
    (string-append "(" (fatify "_") "__________)")  )
  (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) '()) ))
(define (get-chins chins)
  (get-scale-goon 0 chins))
(map  display-nl (get-chins chins))
(map  display-nl (get-scale-goon fats chins))
(exit)

Ruby

if ARGV.length < 1 
        puts "Do it better, girth + chins"
        Kernel.exit
end
head = [" __________","(--[ .]-[ .]","(       O  )"]
ARGV[1].to_i.times do 
        head.push("(          )")
end
head.last.gsub!(/ /,"_")
head.each do |line|
        puts line.insert(1,(0..ARGV[0].to_i).inject("") { |girth, cuteness| girth + line[1,1].to_s})
end

LabView 8 VI

Image:scalegoonfront.png Image:scalegoonblock.png

Ada '95

scalegoonhelper.ads

with Ada.Strings; use Ada.Strings;

package ScalegoonHelper is
function CreateInsert (Width : Integer; Char : Character) return String;

end ScalegoonHelper;

scalegoonhelper.adb

package body ScalegoonHelper is
function CreateInsert (Width : Integer;
                       Char : Character) return String is
        Insert : String(1..Width);
begin
        for I in 1..Width loop
                Insert(I) := Char;
        end loop;

        return Insert;
end CreateInsert;
end ScalegoonHelper;

scalegoon.adb

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with ScalegoonHelper; use ScalegoonHelper;

procedure ScaleGoon is
        Chincount : Integer := 0;
        Goonwidth : Integer := 0;
        Insert : Unbounded_String;
begin
        if Argument_Count >= 1 then
                Chincount := Integer'Value(Argument(1));
        end if;

        if Argument_Count >= 2 then
                Goonwidth := Integer'Value(Argument(2));
        end if;

        Insert := To_Unbounded_String(CreateInsert(Goonwidth, '_'));
        Put_Line(To_String(" " & Insert & "__________"));
        Insert := To_Unbounded_String(CreateInsert(Goonwidth, '-'));
        Put_Line(To_String("(-" & Insert & "-[ .]-[ .]"));

        Insert := To_Unbounded_String(CreateInsert(Goonwidth, ' '));
        if Chincount > 0 then
                Put_Line(To_String("(" & Insert  & "       O  )"));
        end if;

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

        Insert := To_Unbounded_String(CreateInsert(Goonwidth, '_'));

        if Chincount = 0 then
                Put_Line(To_String("(" & Insert & "_______O__)"));
        else
                Put_Line(To_String("(" & Insert & "__________)"));
        end if;

end ScaleGoon;
Personal tools