Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Test your skills (2005)
Index -> General Programming
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Hikaru79




PostPosted: Tue Dec 13, 2005 7:05 am   Post subject: (No subject)

Java:
import java.util.*;

public class OldArrayListTest {
   public static void main(String[] args) {
      ArrayList<String> a = new ArrayList<String>();
      a.add("hello");
      a.add("world");
   }
}


Like so? Smile
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Dec 13, 2005 9:54 am   Post subject: (No subject)

Nope, but thanks for playing our game. The code I posted should compile without alteration.
Hikaru79




PostPosted: Tue Dec 13, 2005 3:48 pm   Post subject: (No subject)

wtd wrote:
Nope, but thanks for playing our game. The code I posted should compile without alteration.


Oooh. I misread the question. You want the actual command used to compile it. In that case,
code:
javac -nowarn OldArrayListTest.java
There Smile No more warning.
wtd




PostPosted: Tue Dec 13, 2005 4:43 pm   Post subject: (No subject)

Hikaru79 wrote:
wtd wrote:
Nope, but thanks for playing our game. The code I posted should compile without alteration.


Oooh. I misread the question. You want the actual command used to compile it. In that case,
code:
javac -nowarn OldArrayListTest.java
There Smile No more warning.


Not quite there yet. Turning off warnings is cheating. Smile
Hikaru79




PostPosted: Tue Dec 13, 2005 5:09 pm   Post subject: (No subject)

wtd wrote:
Not quite there yet. Turning off warnings is cheating. Smile

Drat Sad But it technically does do what you asked Wink

How about this?
code:
javac -source 1.4 OldArrayListTest.java
wtd




PostPosted: Tue Dec 13, 2005 5:26 pm   Post subject: (No subject)

Hikaru79 wrote:
wtd wrote:
Not quite there yet. Turning off warnings is cheating. Smile

Drat Sad But it technically does do what you asked Wink

How about this?
code:
javac -source 1.4 OldArrayListTest.java


It's about time you figured it out. Smile
wtd




PostPosted: Wed Dec 14, 2005 8:15 pm   Post subject: (No subject)

O'Caml TYS:

Given a function "find" which takes a "'a list" and a "'a" and returns None if the list doesn't contain the specified element, and Some int indicating the position in the list if it does...

Take this code:

code:
match find some_list some_value with
   | None -> print_endline "Not found"
   | Some pos -> print_endline ("Found it at: " ^ string_of_int pos)


And modify it such that "Found it at: " becomes "Found it at even: " if the position is an even number. If it's odd, the message should remain the same as in the above code.

You may not use "if" or "else".
wtd




PostPosted: Fri Dec 16, 2005 2:37 am   Post subject: (No subject)

Haskell TYS:

Reimplement Haskell's zipWith function. Replicate all of zipWith's functionality and behaviors. To avoid ambiguity, call your function "myZipWith".

You may not use "if", "case", or "|", and your function should consume at most two lines.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Fri Dec 16, 2005 8:02 pm   Post subject: (No subject)

wtd wrote:
O'Caml TYS:

Given a function "find" which takes a "'a list" and a "'a" and returns None if the list doesn't contain the specified element, and Some int indicating the position in the list if it does...

Take this code:

code:
match find some_list some_value with
   | None -> print_endline "Not found"
   | Some pos -> print_endline ("Found it at: " ^ string_of_int pos)


And modify it such that "Found it at: " becomes "Found it at even: " if the position is an even number. If it's odd, the message should remain the same as in the above code.

You may not use "if" or "else".


code:
match find some_list some_value with
   | None -> print_endline "Not found"
   | Some pos when pos mod 2 == 0 -> print_endline ("Found it at even: " ^ string_of_int pos)
   | Some pos -> print_endline ("Found it at: " ^ string_of_int pos)
wtd




PostPosted: Wed Dec 21, 2005 5:05 pm   Post subject: (No subject)

Ok smartguy...

Redefine List.map in terms of List.fold_left.

code:
let map f = ...
Geminias




PostPosted: Tue Dec 18, 2007 6:10 pm   Post subject: RE:test your skills (2005)

I guess I'll give her a go:

1. Do you know what all of the different uses of "const" or "static" mean?

const prevents an initialized value from changing. It can also be used to specify that a method will not change any data in the class. It can also be used in a function/method to prevent a certain parameter from being reassigned.

static is either a containment specifier that allows you to tell the compiler to store a variable in global memory, or it is something else that I dont know what it is called but allows you to specify static members or functions of a class so that you can access them without an instance of that class and the data is accessible by all instances of this class.

2. Do you understand why a normal class can be split into a header and a ".cpp" source file, but a templated class cannot?

This is not true, you can #include "object.cpp" at the bottom of the header file to give the compiler information about the template.

3. Do you understand why you shouldn't use identifiers beginning with two underscores, even though it's technically legal?

Someone told me that system libraries and so forth use the __ prefix on some of their variables. Other than that I really don't know.

4. Do you understand the difference between:
c++ / ++c

the first increments c and returns c before the inc. second incs and returns inc value.

5. Do you understand why one of the following works and the other doesn't?

the const keyword on the "a" variable prevents a from being assigned. In the second code the initializer form is used which is allowed. The details of this are sketchy to me because I thought

constructor : initialize(someVal)

translated to: initialize = someVal.

to be continued... please give feedback in the meantime
OneOffDriveByPoster




PostPosted: Tue Dec 18, 2007 7:31 pm   Post subject: (No subject)

wtd @ Wed Jan 12, 2005 7:16 pm wrote:
In conjunction with number 2, I need to return zero to indicate the program finished successfully.
No; not really. Some versions of GCC are buggy in that respect though (IIRC). (I am making the assumption that posting to old TYS threads with answers, etc. is not necroposting).
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 10 of 10  [ 147 Posts ]
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Jump to:   


Style:  
Search: