help for a beginner please! 
Author Message
 help for a beginner please!

I am trying to do the following:

1) Find the 3rd element of a list
2) whether a list is a concatenation of three copies of the same sublist.

All this by only using 'append.' I'm so confused about this problem that I
don't know where to start. I've thought about and tried to write some code
but I'm at a very confused stage! please if you can give me a start I would
be eternally grateful.



Fri, 30 May 2003 15:01:59 GMT  
 help for a beginner please!


Quote:
>I am trying to do the following:

>1) Find the 3rd element of a list
>2) whether a list is a concatenation of three copies of the same sublist.

>All this by only using 'append.' I'm so confused about this problem that I
>don't know where to start. I've thought about and tried to write some code
>but I'm at a very confused stage! please if you can give me a start I would
>be eternally grateful.

For 1 you don't even need to use 'append'.  X is the third element of a
list if the first element is something, and the second element is
something, and the third element is X.

A list is a concatenation of three copies of the same sublist if you can
append something to itself and then append that same thing to the
concatenation, and get the given list.

Nick
--



Sun, 01 Jun 2003 03:41:50 GMT  
 help for a beginner please!
Start from chapter 1

if you don't have a book, there's plenty of tutorials available on the web

1) find the 3rd element of a list?
find_third([_, _, THIRD | _ ], THIRD).

test with
find_third([h, e, l, l, o], THIRD).

2) concatenation of three copies
- only one level deep
triple([A, A, A | _ ]) :- !.
triple([A, B, C | TAIL]) :-
triple([B, C | TAIL]).

test
triple([h, e, l, l, l]).

good luck
if you haven't figured out the code above, tough shit

Kee


Quote:
> I am trying to do the following:

> 1) Find the 3rd element of a list
> 2) whether a list is a concatenation of three copies of the same sublist.

> All this by only using 'append.' I'm so confused about this problem that I
> don't know where to start. I've thought about and tried to write some code
> but I'm at a very confused stage! please if you can give me a start I
would
> be eternally grateful.



Sun, 01 Jun 2003 21:55:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Process - Please Help a Beginner

2. Help Please Fig Forth question from Forth beginner

3. Help for beginner ???pLease!!!

4. Beginner-help please

5. please help a beginner ...

6. Please help a beginner

7. Beginner-- Help Please!!!!

8. question from a beginner please help

9. Please help a beginner

10. masm beginner needs help please

11. Please help beginner!!!

12. beginner-please help

 

 
Powered by phpBB® Forum Software