SlideServe
Menu
Préférences
© SlideServe · v2026

ITEC 320

star avatar
13 diapositives · 326 Views · Jul 19, 2014

ITEC 320. Lecture 6 In-class coding Functions. Review. Types Homework Website is up Questions?. VIM. Dr. Okie has been providing VIM information Do you want a VI tutorial? What are the advantages of knowing a power editor?. Outline. Procedures Functions Problems. Functions.

ITEC 320 - slide 1
01 / 13ITEC 320
1 / 17

Télécharger la présentation

ITEC 320
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. ITEC 320 Lecture 6 In-class coding Functions

  2. Review • Types • Homework • Website is up • Questions?

  3. VIM • Dr. Okie has been providing VIM information • Do you want a VI tutorial? • What are the advantages of knowing a power editor?

  4. Outline • Procedures • Functions • Problems

  5. Functions • Similar to java methods with a non-void return type • Must have a return type • Must be defined before use • Cannot modify parameters

  6. Syntax function sumArray(a: Int_Array) return integer is s: Integer := 0; -- holds the sum begin for i in a'range loop s := s + a(i); end loop; return s; end sumArray;

  7. Procedures • No return type allowed • Parameters can be changed • In (default) • Out (allows passing back to the caller) • In Out (pass in and out) • What about the get procedure’s parameter? • Structure charts help

  8. Syntax with ada.text_io; use ada.text_io; with ada.integer_text_io; use ada.integer_text_io; procedure inout is procedure vars(a: in Integer; b: in out Integer; c: out Integer) is begin b:= b+a; c:= b+3; end vars; x: Integer; y: Integer; z: Integer; begin x:=2; y:=3; vars(x,y,z); put(x'img & "|" & y'img & "|" & z'img); end inout;

  9. Issues • Assigning to an in parameter • Using an out parameter’s values in the procedure (by default it can be anything) • Forgetting to assign a value to an out parameter • Can’t fool variables • I.e. passing an in mode variable to another procedure where it is an out mode parameter

  10. Discussion • Web example

  11. Problems • Write a function/procedure that returns whether or not a String is a palindrome

  12. Problems • Given n of 1 or more, return the factorial of n, which is n * (n-1) * (n-2) ... 1. Compute the result recursively (without loops).

  13. Summary • Functions • Procedures