# Create "random" function in processing.js?

**URL:** <https://discourse.processing.org/t/create-random-function-in-processing-js/12777>\
**Category:** Coding Questions\
**Created:** [July 18, 2019, 6:42am UTC](https://discourse.processing.org/t/create-random-function-in-processing-js/12777 "2019-07-18T06:42:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![demsp](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@demsp](https://discourse.processing.org/u/demsp)\
**Post date:** [July 18, 2019, 6:42am UTC](https://discourse.processing.org/t/create-random-function-in-processing-js/12777/1 "2019-07-18T06:42:42Z")

</div>

This function turn back a random number

```auto
IntList listRand;
void setup() {
 listRand=new IntList();
// void draw() { }

int randm(int a,int b){
int y;  
int x=int( random(a,b) );
 if (listRand.hasValue(x) == false) 
 {
  listRand.append(x); 
  y=x; 
 }
 else y=randm(a,b);
 return y;
}

```

But there isn’t the IntList in **processing.js**  
Is there analog/equivalent of _hasValue()_ function for arrays in **processing.js**?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 18, 2019, 7:23am UTC](https://discourse.processing.org/t/create-random-function-in-processing-js/12777/2 "2019-07-18T07:23:26Z")

</div>

-a- something is wrong with the posted code,  
as your question is about  
processing.js  
why you not show us the problem code MCVE at  
[https://www.openprocessing.org](https://www.openprocessing.org)

-b- but i see  
[http://processingjs.org/reference/ArrayList/](http://processingjs.org/reference/ArrayList/)  
try if that helps?  
( i was looking for arraylist.shuffle() , but also not exists )

-c- is your question about

- intlist?

or as the title says about

- function making random?

did you check on  
[http://processingjs.org/reference/randomSeed\_/](http://processingjs.org/reference/randomSeed_/)

---

<div class="post-metadata">

**Author:** ![demsp](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@demsp](https://discourse.processing.org/u/demsp)\
**Post date:** [July 18, 2019, 7:46am UTC](https://discourse.processing.org/t/create-random-function-in-processing-js/12777/3 "2019-07-18T07:46:15Z")

</div>

> [@kll](#):
>
> or as the title says about
> 
> - function making random?

yes, function making random and new random number != previous random numbers

Oh, _ArrayList_ function _contains()_ is the analog of _hasValue()_ function and it’s works, thanks 🙂
