Page 1 of 1

help with funcion

Posted: Sun Oct 23, 2011 5:13 am
by bbeni
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))

Re: help with funcion

Posted: Mon Oct 24, 2011 8:29 pm
by Paul
If I understand the question correctly, the function POSITION does what you want.

Re: help with funcion

Posted: Fri Oct 28, 2011 3:49 pm
by virex
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.