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-Language: ENGLISH,ASCII X-Google-Thread: 103376,3009af37fa605de6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-20 07:45:24 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!212.177.105.133!news.mailgate.org!newscore.univie.ac.at!aconews-feed.univie.ac.at!news.tu-graz.ac.at!news.kfunigraz.ac.at!not-for-mail From: Siegfried Gonzi Newsgroups: comp.lang.ada Subject: Re: Ada communicating with other programs Date: Tue, 20 Nov 2001 16:29:31 +0100 Organization: Universitaet Graz Message-ID: <3BFA76DA.4BDD8F36@kfunigraz.ac.at> References: NNTP-Posting-Host: igam08av.kfunigraz.ac.at Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: jerry.kfunigraz.ac.at 1006270408 10828 143.50.39.35 (20 Nov 2001 15:33:28 GMT) X-Complaints-To: usenet@news.kfunigraz.ac.at NNTP-Posting-Date: 20 Nov 2001 15:33:28 GMT X-Mailer: Mozilla 4.7 [de] (WinNT; I) X-Accept-Language: de Xref: archiver1.google.com comp.lang.ada:16723 Date: 2001-11-20T15:33:28+00:00 List-Id: "M. A. Alves" schrieb: > > I often have to deal with big array computations. Currently, I am > > using Clean > > Give us a reference, please. Clean should not become the subject here. A google search will quickly delegate you to their homepage: http://www.cs.kun.nl/~clean/ > > aa) Is it hard in Ada to do "semi command line programming". > > What is that? In Yorick (or Scilab or Matlab) you can do something like this: a=span(0.0,Pi,100) //creating an array from 0.0 to Pi with 100 points b=fft(a) //doing the FFT plg,a //plotting the FFT In Clean I do not have the command line (Matlab or Yorick are interpreters) and I have to compile my program: e.g. creating a 2 dimensional array filled up with values ranging from 0.0 to N (for every row): Clean program: == module makeArray importStdEnv makeArray:: !Int !Int -> !{#{#Real}} makeArray row column = { { j \\ j <- [0..(column-1)] } \\ i <- [0..(row-1)] } Start = makeArray 3 3 == I can use it only after compiling (compiling and linking is the same process in Clean). The array is safe and under the protection of garbage-collection; I could even not call it with inappropiate types,e.g. Start = makeArray 3.0 3.0 > > The Clean program consits of nearly 100 lines of code. I ask here "how > > easy can it be in Ada", because I have been really depressed and asked > > myself why I have to waste my time with such things and is there a > > clearer way extracting the values. > > It is very easy to do it in Ada, but do expect a big number of lines. If > you want tersness use a "write-only" language like any of the C > derivatives outhere e.g. PERL---but then be prepare to waste some serious > time chasing bugs. > Tersness is not my aim (Clean is also a language for re-using code). But I had a hard time to implement it in Clean, because I had to implement some primitives by myself (okay, with pattern-matching �t has been not too time consuming). At the end of the post is a code snippet of the core-code which reads in from a file. > > You you cleary state the specs for the program you're currently > implementing in 100-lines of Clean I can try to show you how to do it in > Ada as your first tutorial ;-) The task was to read the following file into an array( the line numbers and the number of array columns are not know; only the number of header lines are know): here is a header line and maybe many more Day,Time,Val1,Val2,... 01:23:2001,12:23:34,2.3445,233.34,... 02:03:2001,13:45:00,2,344,222.34,... .... .... > > c) Is there an aha experience when one is confronted in Ada with "not > > having the goody called garbage-collection". > > I haven't felt the need for that yet. In Ada you can do everything > keeping the variables under a nice (dynamic as well as static) scope. > (And of course some guys will tell you how garbage collection slows things > down.) In worse cases Clean is only 2 times slower as a tuned (but not inlined) C code. For example a 2 dimensional 1024x1024 FFT in Clean is about 1.5 to 2 times slower as the same C version. The garbage-collection in Clean is one of the best I know (maybe some commercial Lisps are in that ligue). > Welcome to Ada ;-) Time will show... S. Gonzi Only for the curiosity == ADatumTimeStringRead:: !Char !Char {!*{!Real}} !File -> {!*{!Real}} ADatumTimeStringRead char char_d marray file = fill_up 0 marray file where fill_up:: !Int {!*{!Real}} !File -> {!*{!Real}} fill_up n marray file | n == (size marray) = marray #! (string, file) = sfreadline file #! elem = (RealfromDatumTime_String char_d (DStringtoString_List char string)) #! elemo = {x\\x<- elem} = fill_up (n+1) { marray & [n] = elemo } file RealfromDatum_String:: !Char ![!String] -> ![!Real] RealfromDatum_String char [] = [] RealfromDatum_String char [x,y:r] = [ Datum_StringtoReal char x , Time_StringtoReal char y : RealfromString r ] RealfromDatumTime_String:: !Char ![!String] -> ![!Real] RealfromDatumTime_String char [] = [] RealfromDatumTime_String char [x,y:r] = [ (Datum_StringtoReal char x) + (Time_StringtoReal char y) : RealfromString r ] Time_StringtoReal:: !Char !String -> !Real Time_StringtoReal char string = (toReal(hour) + ((toReal(minute))/60.0) + ((toReal(second))/3600.0) ) / 24.0 where string_list = StringtoString_List char string hour = string_list !! 0 minute = string_list !! 1 second = string_list !! 2 Datum_StringtoReal:: !Char !String -> !Real Datum_StringtoReal char string = toReal (day) + toReal ( months !! (toInt month) ) where string_list = StringtoString_List char string day = string_list !! 0 month = string_list !! 1 year = toInt (string_list !! 2) //year:: !Int //year // | toInt (string_list !! 2) >= 0 = toInt (string_list !! 2) + 2000 // = toInt (string_list !! 2) + 1900 // months:: [!Real] months | ( leap year ) = [0.0,0.0,31.0,60.0,91.0,121.0,152.0,182.0,213.0,244.0,274.0,305.0,335.0] = [0.0,0.0,31.0,59.0,90.0,120.0,151.0,181.0,212.0,243.0,273.0,304.0,334.0] // leap :: !Int -> Bool leap y | divisible y 100 = divisible y 400 = divisible y 4 // divisible :: !Int !Int -> Bool divisible t n = t rem n == 0 == AND SO ON