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,de7dd126d6737f3a,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Georg Maubach Newsgroups: comp.lang.ada Subject: Callback in Ada Date: 27 Nov 2010 09:47:12 GMT Message-ID: <8lc2d0Fb6jU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net LlwLOiec+HEvw2ZrimbWAw0MeRi5PsI6KEcKhF7vXee00fIv7o Cancel-Lock: sha1:dber64ngB9E4sXWVWnvbFKThiNs= User-Agent: Pan/0.132 (Waxed in Black) Xref: g2news2.google.com comp.lang.ada:16643 Date: 2010-11-27T09:47:12+00:00 List-Id: Hi All, today I learnt what a callback function is and also how it is used in Python. I have tested the following code which runs in Python: def apply_to (function, valueList): resultList = [] if __debug__: print "Calling function ", function for value in valueList: if __debug__: print "value: ", value r = function (value) if __debug__: print "result: ", r resultList.append(r) return resultList def dublicate (value): return (value * 2) def power (value): return (value * value) valueList = [1, 2, 3, 4, 5] double_values = apply_to(dublicate, valueList) power_values = apply_to(power, valueList) print "Values doubled: ", double_values print "Values powered: ", power_values Reference: http://en.wikipedia.org/wiki/Callback_(computer_science) If put into a file called "callback-test-in-python.py" and called python -O callback-test-in-python.py it will deliver the output Values doubled: 2, 4, 6, 8, 10 Values powered: 1, 4, 9, 16, 25 How would I do that in Ada? Regards George