From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c5f189513e1f5f8a X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 24 Mar 2009 02:41:39 +0100 From: Gautier User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.18) Gecko/20081031 SeaMonkey/1.1.13 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada as a first language References: <01d59695$0$20632$c3e8da3@news.astraweb.com> <1YudnblPCIBgtlrUnZ2dnUVZ_tbinZ2d@earthlink.com> <87r60oip8a.fsf@nbi.dk> <7NadnVUQy9Nzm1XUnZ2dnUVZ_geWnZ2d@earthlink.com> In-Reply-To: <7NadnVUQy9Nzm1XUnZ2dnUVZ_geWnZ2d@earthlink.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 85.0.195.240 X-Original-NNTP-Posting-Host: 85.0.195.240 Message-ID: <49c83a1c$1_3@news.bluewin.ch> X-Trace: news.bluewin.ch 1237858844 85.0.195.240 (24 Mar 2009 02:40:44 +0100) Organization: Bluewin AG Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 Path: g2news2.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!wns14feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.bluewin.ch!not-for-mail Xref: g2news2.google.com comp.lang.ada:5215 Date: 2009-03-24T02:41:39+01:00 List-Id: Brian wrote: > Since hobbyist, beginner code tends to be small (Less than 1K SLOC/project, and usually much > smaller), then other languages might tend to give him more success with less > pain. I would put the line rather around 100 lines. And even so... I often do less than 100 lines hobby programs without too much pain in Ada. I just made this one with a buddy who was sure it would be more complicated in some script language (and would be a lot slower of course): with Graph; use Graph; procedure Fractal is subtype Real is Float; type Pt is record x,y: Real; end record; subtype Vector is Pt; type Figure is array(Positive range <>) of Pt; type Matrix22 is array(1..2,1..2) of Real; function "+"(p: Pt; v: Vector) return Pt is begin return (p.x+v.x, p.y+v.y); end; function "*"(M: Matrix22; p: Pt) return Pt is begin return (M(1,1) * p.x + M(1,2) * p.y, M(2,1) * p.x + M(2,2) * p.y); end; type Affine is record M: Matrix22; v: Vector; end record; type Affine_array is array(Positive range <>) of Affine; function Morph(f: Figure; a: Affine) return Figure is mod_f: Figure(f'Range); begin for i in f'Range loop mod_f(i):= a.M*f(i) + a.v; end loop; return mod_f; end Morph; procedure Draw(f: Figure; a: Affine_array; level: Natural) is begin if level = 0 then Point( f(f'Last).x, f(f'Last).y ); for i in f'Range loop LineTo( f(i).x, f(i).y ); end loop; else for i in a'Range loop Draw( Morph(f,a(i)), a, level-1 ); end loop; end if; end Draw; procedure Plot(f: Figure; a: Affine_array; d:device_type; n:string) is begin InitGraph(d, file_name=>n); Set_math_plane(0.0,0.0, 1.0,1.0, d); for level in 1..10 loop Draw( f, a, level); ClearDevice; end loop; CloseGraph(d); end Plot; procedure Plot_Sierp(d:device_type; n:string) is triangle: Figure:= ((0.0,0.0), (0.5, 0.886), (1.0,0.0)); M: Matrix22:= ((0.5,0.0),(0.0,0.5)); v1: Vector:= (0.0,0.0); v2: Vector:= (0.5,0.0); v3: Vector:= (0.25,0.886/2.0); transformations: Affine_array:= ( (M,v1), (M,v2), (M,v3) ); begin Plot( triangle, transformations, d, n); end Plot_sierp; begin Plot_sierp(PostScript, "sierpinski.ps"); end; _________________________________________________________ Gautier's Ada programming -- http://sf.net/users/gdemont/ NB: For a direct answer, e-mail address on the Web site!