what in the flying fffff was evolution option CDR CONS question (1 Viewer)

Terra_Niux

l337 h4x0r
Joined
Feb 5, 2004
Messages
93
Gender
Male
HSC
N/A
I think CDR 2 means extract the 2nd atom

CDR (2, [a,b,c,d] = b

Extracts the second atom which is b

Meh I dunno
 

Archman

Member
Joined
Jul 29, 2003
Messages
337
Gender
Undisclosed
HSC
N/A
CONS is adding the element in front the list
CDR is extracting the specified element form the list.
 

hfis

Dyslexic Fish
Joined
Aug 5, 2004
Messages
876
Location
Not China
Gender
Undisclosed
HSC
N/A
Wild Dan Hibiki said:
how about the inputting n = 3 q, wtf were we sposed to talk about?
C) was fairly easy (the n=3 one). In both cases, the 'answer' was 6.

With function a, recursion is used as a mthod of repetition, and a(1) is used as the base case - therefore, it is a member of the functional paradigm. Working is similar to
a(3)
-> 3 * a(2)
2 * a(1)
1

So, result = 2*3 = 6.

With the second one, control structures (a while loop) are used, so it belongs to the imperitive paradigm. Once again, the result is 6;

b(3)
Pass ---- Result ---- K
0 ---- 1 ---- 1
1 ---- 1 ---- 2
2 ---- 2 ---- 3
3 ---- 6 ---- 4 (k > n, break loop. Result is 6.)
 

Archman

Member
Joined
Jul 29, 2003
Messages
337
Gender
Undisclosed
HSC
N/A
well for one of them u get a(3) = 3*a(2) = 3*2*a(1) = 3*2*1 = 6
the other one: b(3) = 1 * 1 * 2 * 3 = 6
so basically both of them calculates n!
then u hafta analyse what paradigm they are from, which i didnt like very much
 

scorpi0n

New Member
Joined
Oct 28, 2004
Messages
19
Gender
Male
HSC
2004
hfis said:
C) was fairly easy (the n=3 one). In both cases, the 'answer' was 6.

With function a, recursion is used as a mthod of repetition, and a(1) is used as the base case - therefore, it is a member of the functional paradigm. Working is similar to
a(3)
-> 3 * a(2)
2 * a(1)
1

So, result = 2*3 = 6.

With the second one, control structures (a while loop) are used, so it belongs to the imperitive paradigm. Once again, the result is 6;

b(3)
Pass ---- Result ---- K
0 ---- 1 ---- 1
1 ---- 1 ---- 2
2 ---- 2 ---- 3
3 ---- 6 ---- 4 (k > n, break loop. Result is 6.)
spot on :) at least i hope so, thats exactly what i said :p
 

Wild Dan Hibiki

teh sex0r
Joined
Feb 28, 2004
Messages
649
Gender
Undisclosed
HSC
2004
oh dear.... i wrote it as 6a cause i had no idea wat was going on
and for the second one.... wait i got 6 for that as well
LOL hopefully i wond lost that many marks
 

MedNez

:o>---<
Joined
Aug 21, 2004
Messages
3,004
Gender
Male
HSC
N/A
Ah.. I saw functional and panicked, but they were really easy.

The first 2 evaluations with CON and CDR were given away by the rules.

The second two, I got 6a for one ( had no idea why the a would dissapear ), and 6 for the second one.
 

Archman

Member
Joined
Jul 29, 2003
Messages
337
Gender
Undisclosed
HSC
N/A
the a is not a pronumeral, a(n-1) is a fuction.
 

MedNez

:o>---<
Joined
Aug 21, 2004
Messages
3,004
Gender
Male
HSC
N/A
Ah crap. Maybe they'll be generous because I had a 6 in the answer?? Worth praying for :p
 

Ditfos

New Member
Joined
Sep 9, 2004
Messages
7
Location
Dubbo
Gender
Male
HSC
N/A
ah, bugger, for b(n) I misread the 5th line as {result = result * n
which means I end up finding n^n, in this case 27. Got the a(n) though.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top