help with funcion

Discussion of Common Lisp

help with funcion

Postby bbeni » Sun Oct 23, 2011 5:13 am

I want make function in lisp, because I have it in java

void index()
{ for(int j=0;j<zoznamP.length;j++){
if (zoznamP[j].equals("2")) indexM=j;}, where String [] zoznamP={"2","3","4"} ;

so i call function (funcion 3) and it returns 2, List I want declared:(defparameter *list* '(3 5 6 8 4 2 1 9))
Posts: 1
Joined: Sun Oct 23, 2011 4:58 am

Re: help with funcion

Postby Paul » Mon Oct 24, 2011 8:29 pm

If I understand the question correctly, the function POSITION does what you want.
Posts: 106
Joined: Tue Jun 02, 2009 6:00 am

Re: help with funcion

Postby virex » Fri Oct 28, 2011 3:49 pm

Do you want a function that does that, or do you want to write one yourself?

In the first case, you're looking for the index of the element that is equal to the provided value, and the function that does this is position.

If you want to write one yourself, the most succinct and easy way for you would probably be to use the loop macro.
Posts: 17
Joined: Fri Oct 28, 2011 3:41 pm

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 4 guests