Get the Peak Value of Integer

Hey there @JakOak! I’ve got a quick little implementation you can use, but I’d definitely tweak it a bit towards your use case. I’ll step through how it works.

I took your basic implementation of the distance function and logic before and left that alone. I skipped the truncate, you can do that at the end if you’d like.

So I made a gate to stop it from polling all the time and two events that open and close it so you can trigger when you want to start polling. So what happens is that the current distance is checked against the current highest listed. If it is higher it sets the highest val variable to it, then prints it. This effectively makes it only print values higher than the last, so while you’re ascending you’ll see a ton of these messages, but when you lower the distance you’ll get none (as the branch will fail and not fire it) even if you’re still recording it.

Let me know if you have any questions!

3 Likes