lista6 .pdf
File information
Original filename: lista6.pdf
Title: Microsoft Word - lista6.doc
Author: zs
This PDF 1.4 document has been generated by PScript5.dll Version 5.2.2 / Acrobat Distiller 8.1.0 (Windows), and has been sent on pdf-archive.com on 14/11/2012 at 19:16, from IP address 156.17.x.x.
The current document download page has been viewed 910 times.
File size: 115 KB (1 page).
Privacy: public file
Share on social networks
Link to this file download page
Document preview
Paradygmaty programowania - ćwiczenia
Lista 6
1. (Scala) Zapisz w języku Scala zaprezentowane na wykładzie funkcje swap, partition, quick
i quicksort, zachowując ich styl programowania. Funkcje nie muszą być polimorficzne.
2. (Scala) Jedna z pętli w języku Scala ma następującą składnię: while (warunek) wyrażenie.
Napisz w Scali funkcję whileLoop, która pobiera dwa argumenty: warunek i wyrażenie
i symuluje działanie pętli while. Jakiego typu muszą być argumenty i wynik funkcji?
Działanie programów z zadań 3-4 należy wyjaśniać, rysując „obrazy pamięci” tych
programów, tzn. rysując referencje w postaci strzałek, komórki pamięci i ich zawartości.
3. Co i dlaczego wydrukuje poniższy program w Javie?
public class Porównanie{
public static void main(String[] args){
String s1 = "foo";
String s2 = "foo";
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
String s3 = new String("foo");
System.out.println(s1 == s3);
System.out.println(s1.equals(s3));
}
}
4. Co i dlaczego wydrukuje poniższy program w Javie?
public class Aliasy{
public static void main(String[] args){
int[] ints = {1,2,3};
for(int i : ints) {
System.out.println(i); i = 0;
}
for(int i : ints)
System.out.println(i);
int[] ints2 = ints;
for(int i=0; i<ints2.length; i++) {
System.out.println(ints2[i]); ints2[i] = -1;
}
for(int i : ints)
System.out.println(i);
}
}

Link to this page
Permanent link
Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..
Short link
Use the short link to share your document on Twitter or by text message (SMS)
HTML Code
Copy the following HTML code to share your document on a Website or Blog