[Question]
  [
As input you will receive
* An integer \$a\$
* A list of integers that is *infinite* and *strictly-monotonic*1.
Your program should check **in finite time** if \$a\$ appears the list.
You should output one of two distinct values. One if \$a\$ appears in the list and the other if \$a\$ does not.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so answers will be scored by their length in bytes with fewer bytes being better.
---
You may take an infinite lists in any of the following formats:
* A list, stream, iterator or generator if your language allows them to be infinite.
* A function or pointer to a function that outputs the next value when queried with no input.
* A function or pointer to a function that outputs the \$n\$th value when passed \$n\$ as an input.
Additionally you may repeatedly query STDIN with the assumption that each query will provide the next term in the sequence.
---
## Test cases
Since I cannot put infinite lists in the body of a challenge I will provide the first couple terms along with a description of the list and a definition in Haskell.
```
6
1 2 3 4 5 6 7 8 9 10 ... (positive integers) l=[1..]
 =>
True
```
---
```
6
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 ... (negative integers) l=[-1,-2..]
 =>
False
```
---
```
109
0 2 4 6 8 10 12 14 16 18 20 ... (non-negative even integers) l=[0,2..]
 =>
False
```
---
```
-5
200 199 198 197 196 195 194 193 192 ... (integers smaller than 201) l=[200,199..]
 =>
True
```
---
```
256
1 2 3 5 8 13 21 34 55 89 144 ... (unique Fibonacci numbers) l=1:2:zipWith(+)l(tail l)
 =>
False
```
---
```
1
1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 ... (integers less than 2) l=[1,0..]
 =>
True
```
1: A strictly monotonic sequence is either entirely increasing or entirely decreasing. This means if you take the differences between consecutive elements they will all have the same sign.
  
[Answer]
# [Python 2](https://docs.python.org/2/), 43 bytes
Takes as input the target integer \$a\$, and a lambda function \$g\$. Since the list is always either strictly increasing or decreasing, we only need to check if \$a\$ appears in the next \$ |a-g(0)|+1 \$ numbers.
```
lambda a,g:a in map(g,range(abs(a-g(0))+1))
```
[Try it online!](https://tio.run/##bY9BCsIwEEX3nuKDm8SmkFQUFN16ApdupjatgTYtaQtx49VrClIjuJuZvHl/0j2HR2uzqTzfppqavCCQqI4EY9FQxyrhyFaaUd4zSismOU8U51PnjB1Qsr3AZ80f4ZFAcaxxdaNerf4yLz8DF6r7iFDy8OvZIPuDpbuYyqRECv/NK02OcwQomDK4TqHQwYPwznxYCepkaRRf9Fsp5vESDFbou9PU6wJDi61EMeq5GsjUcPo@ut60lkf/ED/x0XXTGw "Python 2 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 33 bytes
```
t#l@(a:r)=t==a||(a<t)==(l<r)&&t#r
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/v0Q5x0Ej0apI07bE1jaxpkYj0aZE09ZWI8emSFNNrUS56H9uYmaegq1CSr5CQVFmXolCtEKmgrJCtLGOqZ5erEINkGejqxBtoKdnGasQy6UAByiqzbGq/g8A "Haskell – Try It Online")
[Answer]
# [convey](http://xn--wxa.land/convey/), ~~[144](https://codegolf.stackexchange.com/revisions/216260/1)~~ 92 bytes
```
 v<<<<<<<<<<<
>;  >">>??>=@]
"">>,<1[v)>#,
v}^>)?:`(#>#^
v{^"9>v]^",^
>;@">>@`"#^
1>0   >>>^
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoiIHY8PDw8PDw8PDw8PFxuPjsgID5cIj4+Pz8+PUBdXG5cIlwiPj4sPDFbdik+IyxcbnZ9Xj4pPzpgKCM+I15cbnZ7XlwiOT52XV5cIixeXG4+O0BcIj4+QGBcIiNeXG4xPjAgICA+Pj5eIiwidiI6MSwiaSI6IjUgMyA0IDYgNyA4IDkgMTAgMTEgMTIgMTMgMTQgMTUgMTYgMTcgMTggMTkgMjAgMjEgMjIgMjMgMjQgMjUgMjYgMjcgMjggMjkgMzAgMzEgMzIgMzMgMzQgMzUgMzYgMzcgMzggMzkgNDAgNDEgNDIgNDMgNDQgNDUgNDYgNDcgNDggNDkgNTAgNTEgNTIgNTMgNTQgNTUgNTYgNTcgNTggNTkgNjAgNjEgNjIgNjMgNjQgNjUgNjYgNjcgNjggNjkgNzAgNzEgNzIgNzMgNzQgNzUgNzYgNzcgNzggNzkgODAgODEgODIgODMgODQgODUgODYgODcgODggODkgOTAgOTEgOTIgOTMgOTQgOTUgOTYgOTcgOTggOTkgMTAwIDEwMSAxMDIgMTAzIDEwNCAxMDUgMTA2In0=)
[![Gif](https://i.stack.imgur.com/KeYmp.gif)](https://i.stack.imgur.com/KeYmp.gif)
Input is given as a list of integers with the first integer being the goal and the remaining being the list. Since there is no way to accept infinite input, this program instead only consumes a prefix of the input. You can see this in that there is a very long relay line to stop additional input.
### Explanation
To start we need to split the first element off the input, to be used. To do this I use a simple switch, and because we want to use the input a bunch I feed it into a sort of generating vortex to continuously pump out new copies.
[![Explanation 0](https://i.stack.imgur.com/uiWsj.gif)](https://i.stack.imgur.com/uiWsj.gif)
Now we split the main stream in two, and calculate the differences on one of the parts. This will tell us if the list is ascending or descending.
[![Explanation 1 (Ascending)](https://i.stack.imgur.com/2Wu8a.gif)](https://i.stack.imgur.com/2Wu8a.gif)
[![Explanation 1 (Descending)](https://i.stack.imgur.com/FDXNp.gif)](https://i.stack.imgur.com/FDXNp.gif)
Now we use the difference stream to redirect the main stream, to the two different comparison sites. If the list is ascending we want to go until the element is greater than or equal to n if it is descending we want to go until it is less than or equal to n.
[![Explanation 2](https://i.stack.imgur.com/wE4ZL.gif)](https://i.stack.imgur.com/wE4ZL.gif)
So that stream coming out now will give us some ones and then at some point switch to zeros. What we are concerned about is the first number that gives a zero. We want to know if it is equal to n. So we create another stream and get whether that is equal to n.
[![Explanation 3](https://i.stack.imgur.com/P8Csw.gif)](https://i.stack.imgur.com/P8Csw.gif)
At this point I'm going to stop with the gifs, since they really look like the end product mostly. We redirect the streams with each other, discarding all the elements before the comparison starts giving zero. Then we use a lock to grab just the first equality. We output this and send a signal to stop taking input. With no input the machine slowly winds down and halts.
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 61 bytes
```
def f(l,v):
 a=l()
 while(a-v)*(b:=a-l())>0:a-=b
 return a==v
```
[Try it online!](https://tio.run/##bY7BbsMgDIbvPIWPsEEFnTptkeirILOQFolAxki2Pn3mRDtU2w6WrO@zf3u6tWvJTy9TXdc@DDDwJBfRMUCbuGDweY0pcFSLeOC@s6iIirPuUFnPoIY210yzdlkvNuHoewQK6Cjm4FwOX805CYtgbKhlhNhCbaWkD4jjVGqDtzLnxth2ec7xfQ5uiJ5v9wHBgqcy1O9fgNkwCblzLwEf/U5uMaQekLGpxtz4he@x3AgJz0L8ospIUP8rLeFIwujXP@qo9c@aOt3J@6dp@USZ6zc "Python 3.8 (pre-release) – Try It Online")
Input is a function that returns the next value on every call and an integer.
---
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~70~~ 69 bytes
1 byte shorter thanks to @JonathanAllan.
```
def g(l,v):
 a=next(l)
 while(a-v)*(b:=a-next(l))>0:a-=b
 return a==v
```
[Try it online!](https://tio.run/##bY5BDsIgEEX3nGKWoJBAjUab4FUMWNqSIFSk1Z6@0qYLoy4mmbyXP3@6MbXB745dnKbK1NBgRwdSIlDSm1fCjiB4ttYZrNhANliXUrHVkDMvFZMaQTSpjz5n5DDVMdzAJhNTCO4B9taFmOAaep8Qmit6b@@9udRW47kIFEjQeUTelyoQM86CLlxTUFu9kNEaV4FCqIvWJ9zg5SwWhMKBkC/KBAX2X3EKRRaCn35UwfkaY/sP@fl0Du/zzekN "Python 3.8 (pre-release) – Try It Online")
Input is a generator and an integer, can probably be shorter with one of other input formats.
[Answer]
# [Haskell](https://www.haskell.org/), 43 bytes
```
a#k@(b:c)|k>c=(-a)#map(0-)k|b<a=a#c|1>0=b>a
```
[Try it online!](https://tio.run/##BcFLCoAgEADQw@jCgSaUFlGkdI9oMUqQ@EnKpXe39276whVj78TCLuzqoAXjtEAClqgIiRCa3UgTc00Zqa2hnshnXV6fK89P5QLnBdiBasBpHM/@Aw "Haskell – Try It Online")
This outputs `False` if the integer is present and `True` if it is not although I have added a `not` to the handler because that sort of output is confusing to me.
---
## Explanation
The first check we do is `k>c`, that is whether the input is greater than its own tail. Since this list is strictly monotonic the heads of these lists cannot be equal so `k>c` is a short way of comparing their heads. This check thus tells us whether the first element is larger than the second and by extension whether the input is decreasing. If the input is decreasing we negate everything to make it increasing
```
(-a)#map(0-)k
```
The next check is whether `b<a`, that is the head of the list is less than the thing we are looking for. If it is then we should find `a` later in the list so we discard `b` and go again
```
a#c
```
If that fails then `a<=b` meaning that either `b` is `a` or `b` should come before `a`. Since `b` is the first element we know that the only way for `a` to be present is for it to be `b`. Thus we halt returning
```
b>a
```
Which is a shorter way of writing `b/=a` since we know already that `b>=a`. 
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + GNU utilities, ~~47~~ ~~44~~ ~~43~~ 42 bytes
```
read m
sed 1$[(m-($1))**2]q\;i$m|grep ^$1$
```
[Try the test suite online!](https://tio.run/##rdJtT4JQGAbg7/yKe8kciiRQsoXipu5obIUV6JdetgOe1E3QUFtb9NsJI1n50pzrfDvbc86u3c/t0vko9ugC9Vk4HYbUR612QrrtkzhkdACfm7MBFP5e8CWBVwqFYlF9fHmojnk/GoZshide4eNknuO8kT8dYCm@4fsnjsPXycEhtoOcouOma5uO2ScwLYd0yJ1dgkPDIVtgHCzYkIXQuOdpCEEIDKVaDUSxUEh@eAfzRlPwQfUDEU7La6qGOsoD9loOlpMJkM@nc064ZIii9NKmkznbpKg6LNJpHEqRVhZJWln@nXKWULqWlHFIn1j7TYp8kankVUCG@pcqGT/Wda5nClwR24Zz2bCgysqWSapkJFWW10ntI0mVY0UVHT3LvO0RtM1m12q0Wias3nVzV05qReNoUiGkMnfVJs@gJWq4JVc0vB9AdxOYvD2SyGu7Q9te46@Wp83av8SDNfEn "Bash – Try It Online")
*3 bytes off thanks to user41805's pointing out that a single `sed` could be used to replace both the `echo` and the `head`.*
*1 more byte thanks to user41805 again.*
*And now 1 more from user41805.*
The target integer (the integer \$a\$ in the challenge description) is passed as an argument, and the infinite list is read from stdin. (The challenge says: "Additionally you may repeatedly query STDIN with the assumption that each query will provide the next term in the sequence.")
The output is the program's exit code (0 for truthy, 1 for falsey).
---
**Explanation:**
The program reads the first number in the infinite list into \$m\$.
Let \$a\$ be the target integer that we're looking for (it's `$1` in the program). In principle we need to check, after \$m\$, at most \$\left| m-a \right|\$ additional values in the infinite list, because we're starting at \$m\$ and either going up by at least 1 for each number in the list or going down by at least 1 for each number in the list.
However, the program actually checks (more than) \$(m-a)^2\$ additional values. That's OK, because \$(m-a)^2\ge\left|m-a\right|\$. We may be checking additional (unnecessary) values, but that's harmless.
The original version checked exactly \$(m-a)^2\$ additional numbers (using `head`). Unfortunately, replacing `head -${n}` with `sed -${n}q` doesn't work if the value of `n` is 0, so we need to enlarge the number of items checked. To do this, I simply prepend a `1` to the number (which takes one fewer byte than adding 1 to it).
The golfing benefit in doing all this is that, in bash, squaring a number requires fewer bytes than taking the absolute value of a number (as far as I can see).
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
D¥нdiIë(I(}.i
```
-1 byte thanks to *@Grimmy*.
05AB1E has infinite lists, but no functions. So it assumes the infinite list is already at the top of the stack. Assuming this is [allowed for stack-based languages according to the meta](https://codegolf.meta.stackexchange.com/a/8493/52210), but it explicitly mentions functions, so not sure how to handle it here.
Alternatively, the infinite list can be put in a pre-defined variable (i.e. `X`), in which case this would be 15 bytes with that `X` as additional leading byte.
[Try it online](https://tio.run/##yy9OTMpM/a/kmVdQWlJspaBk72mvpJCYlwJkcT3qmKfB5RJyaDFQ6FHbJKDQf5dDSy/sTcn0PLxaw1OjVi/zv85/MwA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpSbKWgZF9pr6SQmJcCZHE96pinAMQaIMLm0HYFIwNDIEsXxD3cmnZomYIRiKvJ5Xd4hUvIocVAjY/aJgE1/nc5tPTC3pTMysOrNSo1avUy/@v8jzbTMdMxNLDU0TXVMTIFMmMB). The second line of the header contains the infinite list(s). In the output the first 10 values are printed as example sublist, so you know which infinite list was used in the program.
**Explanation:**
05AB1E has a builtin to check if an integer is in an infinite list that is guaranteed to be non-decreasing, which is `.i`. Using that builtin, we have the following program:
```
D         # Duplicate the infinite list at the top of the stack
 ¥        # Take it's deltas / forward-differences
  н       # Pop and push the first difference of this list
   di     # If it's non-negative:
     I    #  Simply push the input-integer
    ë     # Else (it's negative):
     (    #  Negate all values in the infinite list
      I(  #  Push the input-integer, and negate it as well
    }     # After the if-else, where we now have a non-decreasing infinite list
     .i   # Check if the (possibly negative) input we pushed is inside this infinite list
          # (after which the result is output implicitly)
```
Note that this approach only works because the infinite list is guaranteed to be either only increasing or only decreasing. With an infinite list that is both (i.e. \$a(n) = \left\lfloor10\tan(n)\right\rfloor\$ → `[0, 15, -22, -2, 11, -34, -3, 8, -68, -5, ...]`), this approach of course wouldn't work.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~20~~ ~~17~~ ~~16~~ 9 bytes
Takes `a` on STDIN, then a list of values on STDIN.
**Edit:** Wow, under 10 bytes now! Really shows how powerful Pyth is :P
```
}Q+JEmEaJ
```
[Try it online!](https://tio.run/##DcyrDcQwAARRPq1EK3n9dwEhYVfCsZBIASEHrnbHdJ409@855/x/tmO/9u8xpwox4IE7brjigjNOOGLjwKDTqBQyiVUJyCiihDLroYoa6mgsCi8 "Pyth – Try It Online")
Port of @dingledooper's [Python answer](https://codegolf.stackexchange.com/a/203008/58563).
```
}Q+JEmEaJ
 Q              # Initialize Q to be the first input from STDIN
   JE           # Initialize J to be the next input from STDIN
}Q              # Return true if Q is in:
  +             #   The union of 
   JE           #      - the first element of the sequence
     mEaJ(Q)    #      - abs(J-Q) more inputs from STDIN (Q appended implicitly)
```
---
**8 bytes**, if we can return the index of `a` in the list
```
x+JEmEaJ
```
[Try it online!](https://tio.run/##Dcy7DYQwAATRfFpBK3n9dwEkdEF2yUkEBFC9cTpPmuu9f3M@27H/9/OYU4UY8MAdN1xxwRknHLFxYNBpVAqZxKoEZBRRQpn1UEUNdTQWhQ8 "Pyth – Try It Online")
```
x+JEmEaJ
x          (Q)  # Find index of Q in:
 +              #   The union of:
  JEmEaJ(Q)     # J and the next abs(J-Q) elements
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 21 bytes
```
{|/x=y'!1+|/-:\x-y.0}
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6qu0a+wrVRXNNSu0de1iqnQrdQzqOXiSos2szbUjgXTuoa6IIahgaW1kRaIpWtqbWRgABW0rlaJrrAxtDa0zo+u0DWK1QZRhrGxtbEK+grFqSUKJfkKRqZmCoklCpX5pUUK+eV5CkWZxdmKQN3GBtZAswF81CU7)
## Explanation
*x* is number, *y* is function representing infinite list.
* `1+|/-:\x-y.0` equivalent to `1 + abs(x - y(0))`
* `!` range
* `y'` apply *y* to each element
* `|/x=` find *x*
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 33 bytes
```
(@:k\-abs:r;0:g;{(k=g+:g;}r*;r!g+
```
[Try it online!](https://tio.run/##DcbdCkAwAAbQV/ncyVI@Mz9bynvgAmWJos2dPPs4V8eex@oXt113UD2RQ6KAQokKNRowAwnmoAQLUIElWI0h7vQ@pNPstTOZtuaJ99aKP69LjIusCOED "GolfScript – Try It Online")
This is a very, very quick and dirty way of doing this problem.
TL;DR
Check if the first number is the number we're looking for. If not, then find the difference between our number (finite) and the first number (finite) to get the maximum number of elements we need to search (finite). This is a clusterfuck, clumsy, and messy, but it does the job adequately. There's probably a builtin I'm missing, but I'll come back to this later to refine it and to make code short enough worthy of an explanation.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 24 bytes
```
ＮθＮηＮζＷ›Π⁻⟦θη⟧ζ⁰Ｎζ№⟦ηζ⟧θ
```
[Try it online!](https://tio.run/##XcuxCsIwGATg/Z4iY36IYJLWKh0dxEHpXhxqLaQQWxMThb58zChdDr7jrjed7@fOpnSeXjFc4/M@eO6oxr/Nykv214x2YPzkhy7kqvHzI/aBX8YpvnnrBDM3wRYiwbZEbP1u/DgFfpxjztbkYR47ojolVe4goaBRYg@poSR0gTLrAFkUUFpDV1XafOwP "Charcoal – Try It Online") Link is to verbose version of code. Reads each value as a separate line on STDIN and outputs `-` only if `a` appears in the monotonic list. Explanation:
```
Ｎθ
```
Input `a`.
```
ＮηＮζ
```
Input the first two terms of the list.
```
Ｗ›Π⁻⟦θη⟧ζ⁰
```
Repeat while the last term of the list so far lies between `a` and the first term.
```
Ｎζ
```
Read another term from the list.
```
№⟦ηζ⟧θ
```
Output `-` if `a` is the first term or the term just read.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 39 bytes
```
->a,g{[]!=[a]&(0..a*a+g[0]**2).map(&g)}
```
[Try it online!](https://tio.run/##RYzLCsMgEEX3/Yp2I4lGUSGFEsYfERcjNNJFIDQtTAn21y150eU9nHOf7/gpPRTpsEmzDxfwGFillUKOInkdOLe1GnCsWKpzGc@9vzbS0UzC5HD67y/t0@jbJnC7E9muwGotD8m2W4UQwXTkDGOkXo/hPi1IRMDc4XG4mmZpyw8 "Ruby – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 15 bytes[SBCS](https://en.wikipedia.org/wiki/SBCS)
```
{⍵∊⍺⍺⍳1+|⍵-⍺⍺1}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v/pR79ZHHV2PeneB0WZD7RqgiC6Eb1j7P94zLy0zL7Mk1SezuMQ3NTcptag4I7NA4VHbBAUCerm4UstS8yAqjQ5PB0oBhR71TQUJgGVwmW1MlCoTLq681PTEksyyVM@8ktR0oDDELl0UmzDU4DLPiGQdBiTrOLTe@D8A "APL (Dyalog Unicode) – Try It Online") Uses [dingledooper's idea](https://codegolf.stackexchange.com/a/203008/75323).
```
{             } ⍝ Operator accepting function on the left and integer on the right
   ⍺⍺           ⍝ Apply the input function to
     ⍳           ⍝ the range of integers from 1 to
      1+         ⍝ 1 plus
        |        ⍝ the absolute value of
         ⍵-      ⍝ the input number minus
           ⍺⍺1   ⍝ the first value of the input function.
 ⍵∊              ⍝ Finally check if the input number is in that list.
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~7~~ 6 bytes
```
α¬>£0å
```
[Try it online!](https://tio.run/##yy9OTMpM/f@oY56RFpeSZ15BaUmxlYKSvUvIocX2SgqJeSlAjqcLkGlrB2T9P7fx0Bq7Q4sNDi/9r/Pf0MASAA "05AB1E – Try It Online") or [verify all test cases](https://tio.run/##yy9OTMpM/V/G9ahjngIQa4AIm0PbFYwMDIEsXRD3cGvaoWUKRiCupt/hFVxKnnkFpSXFVgpK9i4hhxbbKykk5qUAOZUuQKatHZD1/9zGQ2vsDi02OLz0v87/aDMdMx1DA0sdXVMdI1MgMxYA).
Takes the infinite list input via the stack, like [Kevin's 05AB1E answer](https://codegolf.stackexchange.com/a/203032/6484).
```
α              # absolute difference of the number with each element of the infinite list
               # this list contains 0 iff the original list contains the number
 ¬             # get the first element
  >            # increment
   £           # get the first n elements, where n = first element + 1
    0å         # check if 0 is in those elements
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 31 bytes
```
#2@Range@Abs[#-#2@0]~MemberQ~#&
```
Port of dingledooper's python 2 solution.
[Try it online!](https://tio.run/##y00syUjNTSzJTE78X277X9nIISgxLz3VwTGpOFpZF8g1iK3zTc1NSi0KrFNW@x9QlJlXEu2Yl@LgUM2lUB5tpqOgrKAWq2BrqxBSVJqqAxXThQm6JeYUQ0QNDSx1FIyAqnWBJLqkrilQzsAQKIdhmpEp0Dy3zKT8vMTk5MxoZQVtBcNYTNNBZqPq5qqN/Q8A "Wolfram Language (Mathematica) – Try It Online")
Other similar attempts:
```
⌊#⌋==#&&#>=1&@InverseFunction[#2]@#&
```
and:
```
Tr[1^Solve[#2@x==#,x,PositiveIntegers]]==1&
```
# 9 bytes
Mathematica doesn't have iterators or generators in the same way python does, but Regions and Domains take their place. If you allow Regions as an equivalent,
```
{#}∈#2&
```
just tests if the 1d point of the first argument is in the Region. RAW (Rules as written) don't allow Regions, so I'm going to leave the port as the main answer.
[Try it online!](https://tio.run/##bY/BTsJAFEX3/AZJo9ixZaRNMNbgQhN2ou4mYzKMrzCxnYGZV2xSuuc7@ZHasDBguz057757c4FryAUqKRpImmpYHw@HIfWaV6s0sif9NZtVA2CxP883mZIK32CljGblYzL2q7LmPEk@bAF@r/SQkD/rRWTupI3DaU9a6HnPO9ALVvLOBYl6kmkY/i9Ao06FuUZYgV2w961FFpWf9GbC@X7f5aTlF5@vRmvEjbsPAodCfpsd2DQzP7fS5MG2AIdtvgvo5I7G8TTAFhCVEkF0kS/BEuVIqpZGCynV6Po0vG/F@YZBzZtf "Wolfram Language (Mathematica) – Try It Online")
The best solution is just Mathematica's built-in `Element` over a domain, but Domains do not seem to be able to be defined by the users, only the premade handful exist.
[Answer]
# [Desmos](https://desmos.com/calculator), 41 bytes
```
f(k)=∑_{n=0}^{(k-g(0))^2}0^{(g(n)-k)^2}
```
Because Desmos does not support infinite lists and does not support functions as arguments, the input list should be represented as a function named `g`.
Pretty much a port of dingledooper's [Python answer](https://codegolf.stackexchange.com/a/203008/96039), except I replaced absolute value with square because that is golfier.
[Try It On Desmos!](https://www.desmos.com/calculator/xjeqajjyiq)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/pydv8xfr3c)
[Answer]
# JavaScript (ES7), 49 bytes
*Using [@dingledooper's method](https://codegolf.stackexchange.com/a/203008/58563)*
Takes input as `(integer)(generating_function)`. Returns \$0\$ or \$1\$.
```
n=>g=>(F=k=>k*k>(g(0)-n)**2?0:g(k)-n?F(k+1):1)(0)
```
[Try it online!](https://tio.run/##bc7BCoMwDAbg@54ix6SuoxUcTGi9@R7OqbhKqnPsuFfvKrqTXvpTvpD8z@pTzfWrH9@S/aMJrQlsbGcslsYZ64Sz2KEiySREWqi8Qxc/RYku0ZRrihZqz7MfmsvgO2zxSshgLDAkoIlOx/rlHWl12zAFAXuX2Z@VAnkwkGZxe9vfPRhAPsMYU59hWoLWSgUsHtfIRcZYcYpBkMdn12c7p9dj4Qc "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), 54 bytes
Takes input as `(integer)(generating_function)`. Returns a Boolean value.
```
n=>g=>(F=k=>(v=g(k),g(1)>g(0)?v<n:v>n)?F(k+1):v)(0)==n
```
[Try it online!](https://tio.run/##bY7BDoIwDIbvPkWPrTizkWAioePGeyDCgpDOiNnRV8cZ0Qsc2qT/1/b/b3Wop@bR359K/LWdO56FrWOLFQ@xB3Y40MGhIetQUxkKyYMVKiscEkN5oKgyy9x4mfzYHkfvsMMToQBbEEjAEO226UtWyOjzAlPYw5qr7Ie1BrWxkGbxe9dfPDAsEQowUMbK4aPHcxUzxWD/KaV1jsXGfE3mNw "JavaScript (Node.js) – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 59 bytes
```
t;f(a,p)int*p;{for(t=abs(a-*p)+2;t-->0;)t=*p++-a?t:-1;++t;}
```
Takes a pointer to an "infinite" array. The way I implement this is to only calculate the numbers that are used (and then a "safe buffer" at the end to make sure I don't have any off-by-one errors, but this won't skew the result).
Es un puerto de la solución de [dingledooper](https://codegolf.stackexchange.com/users/88546/dingledooper).
*-1 byte thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!*
[Try it online!](https://tio.run/##rZLRasIwFIbvfYpDYdA0zUw6HMys884n2N0mI63pDKtpSdMNEZ@9SxScDqs4Figh55z/fKfJn5P3PO86y4tQxDVS2kY1XxeVCW0qsiYUJKoRTrgl5IlyZNOoxpiIiR0TxjG2fNM5DSyF0uFnpeZosB6AWz4ojHm5o3TG95GqnL/5T7fLTBpIgcbbnF998bw1Rmr7k2N8sE36IX1T5eu52x6B@R1jtBf7EdQsVZjthqiNUxRhcNM40bNp5asOYijC@9hVIphA4IPBOJiKspEB4teSiCKnUNt2f2aN@n4rSi6wGH24lpb00RJKiTp/jWR0Lc3544C23jOHQ2eYUmkJU5WpSos8V6AasAsJlS5X8CVWYCtnvA95KLILV2RaDUaKxskyV1qIxt4e@ezIaz8HftqMxw7k/c781RqfbL27zZ62m/PPmYz@zajs0luyXtKm@wY "C (gcc) – Try It Online")
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-x`, 24 bytes
```
W(Y(bi))CMa=yCM(bUi)_a=y
```
Uses the third format of infinite list: "A function... that outputs the nth value when passed n as an input." Takes a number and a function as command-line arguments. [Attempt This Online!](https://ato.pxeger.com/run?1=m724ILNgWbSSboVS7IKlpSVpuhY7wjUiNZIyNTWdfRNtK519NZJCMzXjgUyINFTVumhDA0sdBaVqI63EWrheAA)
### Explanation
```
W(Y(bi))CMa=yCM(bUi)_a=y
                          a is the number, b is the function, i is 0 (implicit)
W                         While...
   (bi)                     Call b with argument i
  Y                         Yank the result into y
 (     )CMa                 Compare that value with a (returns -1, 0, or 1)
           =                Equals
            yCM             Compare y with
               (b  )        Call b with argument
                 Ui         Increment i
                          ... loop:
                    _       No-op
                          When the loop exits, we've either reached or passed a
                     a=y  1 if the most recent sequence value equals a, 0 otherwise
                          Autoprint (implicit)
```
[Answer]
# [Perl 5](https://www.perl.org/), 55 bytes
```
sub f{$f=pop;@L=($F=&$f,map&$f,0..abs$_[0]-$F);pop~~@L}
```
[Try it online!](https://tio.run/##zVRNa@MwEL37VwxUbG1itZL8kThCNKeeure9hVCcRuqabWTjD5YQ3L@eHTneXQKhx7oGoa834s3zm6l0/ZacTk23BXMkRlVlJVdPyieP6hsx4T6v3MTu7vJtQ57XbEPJYyAR9f6@eupPNxeBw/H6MpQPof6/2E0PX@bzukaD0Xnb1RpumzZv9a0cDn/opl0uv5e1lt7@4JO27nRITP7W6ED5POzsTptAeqasYX8A0iIefG@dhvjsGQ2A2hyHR4lVXBI7m2HuG4eAGw4CIoghgRTmsIAMOJtcjpH@kGZ4QZ86/pT2f@lTDlQAjYDGQBOgKdA50AXQDOhUiXhrzrLwOn3h5FeiH@kzVD9G5RdOdS6Ax8BT4AsQbEL1aRJeN49g7Cz/SB/3wDO0TIYJZHMcSD5LcGAeWYRDTEBfJOl19Zk0xdZ3/g9cBqP3E6d@BIJDhGWAO8wnjgGhpc1fXopPN89Hpeus/790GXzg/2nMExw9N7teVdgqJL9z22LD6mygVkN3kuM9kNeyVWaEOcD5pvzlDzdqCMXD3tuVVj@72MK@Sm/o9MX2uD@gJs3PwrSSuD2x/f292pW4UIo98KWb@YNYnn865cFsXImg709/AA "Perl 5 – Try It Online")
More or less a translation of @dingledooper's Python2 answer.
[Answer]
# perl -lE, 34 bytes
```
$t=<>;{$_=<>;$_<$t?redo:say$_==$t}
```
[Try it online!](https://tio.run/##K0gtyjH9/1@lxNbGzrpaJR5EqcTbqJTYF6Wm5FsVJ1YCxWxVSmr//7fkMuQy5jLlMucCsgy5LKHgX35BSWZ@XvF/XV9TPQNDg/@6OQA "Perl 5 – Try It Online")
Prints `1` followed by a newline if the first element of the list appears elsewhere; otherwise, it just prints a newline. The program terminates after reading the first number which is equal or larger than the first number.
[Answer]
# [Java (JDK)](http://jdk.java.net/), 67 bytes
```
a->s->{int p=s.get(),n;for(;p*(n=p-s.get())>a*n;)p-=n;return p==a;}
```
[Try it online!](https://tio.run/##dVRdb5swFH3nV1iRIkECVoLUSasLb6s0aasmpX2a9uCAoU7BeLZhq6r89sx8LjgmPET2Pb7ncM8xJ9zg4JS@XWjJK6HASa9hrWgBN8i52ctqlihasbboJAWWEnzHlIEPB@ifVFjRBDwOoIevTJGcCP@HIClNsCIPh5rzghIxluI4BhmIwAUHsQziD8oU4JGEOVGu5zOUVcJFfOOyiAfDrhfjDUMeDyKGBFG1YPpEhNH5grQIXh8LLWFQ0lQ0BaUW6B6UoCz/@QtgkUtv0KuIVO4nv3uF@3teSapoQwZp0kMWECM5XgLtd58nWMWeBuSXhjAbOrgbwXSoHkpcFEQ8v2IW7vbX2PBuElAz@rsmj/RYMZwk9Kkuj6YMs@83ImXb9PlP1eHOjgNmE@qOtaNnhKQF8cGNTeAVv@sTyds4uoNekhJWtYJcT1Zl7mqdrtlarlkU9//ts/KnnisIoV5mEOve726/7cGOe@p@o68LxNwYHZc9@o8Yd0373FHqGJJ5fbvtqWZMhruaKbBRmSEwqYx6ENiorAnRjDsboT1OE2/bsMGFPm1H9ulYoNxGIETX8nUnBG4VD3Gap1RThjubZHuozUlZe1rnZc29EYXewr/qZQEbWnTa75NlslZgP7clbYtaBj8WpWpLWhNMUxY9ubrhC7fD8i1Y8OIKMRpxvvwD "Java (JDK) – Try It Online")
# Credits
* -2 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)
[Answer]
# [C++ (gcc)](https://gcc.gnu.org/), [114 bytes](https://tio.run/##bU89T8MwEN37Kx5mSapWonyWODETzAyMLK7jBkuJbTlnMUT57cFuKyEklrt7el865f22U2pZro1VfWw1auNGCloOYmUs4VjkKcspL78hPlJbVcpYIYjTtpHcHAsqWzf55h9y/v4yvS78mgStqeRBUwwWV8TnJY7GdrBy0KOXSiOZ@alzkMYWJaYVkKGxPhJPQLlIqGuwV0s6wAfXBTmceVRgHKkaQvw6Ds71SK4saE6/pKv8k/Vp3y85F10KykRxhi/sI0TNKvYm@1Gz5J2XB@xwizvc4xFP2OMZu5sf "@ceilingcat deals -8 damage, effective!") 106 bytes
```
#include<iostream>
int f(int a){int p,t;std::cin>>t;if(t-=a)for(;p=t,std::cin>>t,t-=a,p*t>t*t;);return!t;}
```
[Try it online!](https://tio.run/##VU89b8MgEN3zK17pYkeO1PS7xqZTO3fI2IUSbCHZgOCYovx2F5JIbZa7e3pfOuX9ZlRqWW6NVVPa6864SEHLWayMJQxVmbI@lOUb4pH2bauMFYK4GSra9LIeXKi476n5RzaFafyaBK2J1zxoSsHeED8uKRo7wspZRy@VRnbxU9ksja1qHFZAgcb6RDwD5RKh68A@LOkAH9wY5Hzm0YJx5E4I8ef4cW5CdhVBf3oiX/VV1rf9uuRcdDmoENUZvrNdSJq17FNOUbPsPS5P2OIeD3jEM17wijds734B "C++ (gcc) – Try It Online")
---
**Explanation :**
Our only hope of finding \$\alpha\$ in the future terms of the list \$t\$ is if :
* We don't skip over \$\alpha \implies\$ The difference of \$\alpha\$ and \$t\_n\$ doesn't change signs \$\implies \left(\alpha - t\_n\right)\cdot\left(\alpha - t\_{n-1}\right)>0 \space \forall \space n\in N, n > 1\$.(If it is zero, one of the terms is our target)
* The series approaches our target \$\implies {\left| \alpha - t\_n\right|} < {\left| \alpha - t\_{n-1}\right|}\$
We can then combine these two conditions :  
$$
{\left| \alpha - t\_n\right|} < {\left| \alpha - t\_{n-1}\right|}
$$
$$
\implies {\left| \alpha - t\_n\right|} \cdot {\left| \alpha - t\_{n-1}\right|} < {\left( \alpha - t\_{n-1}\right)}^2$$
$$
\text{Since we need that}\left(\alpha - t\_n\right)\cdot\left(\alpha - t\_{n-1}\right)>0,
$$
$$
\text{Condition } P \equiv \left( {\left| \alpha - t\_n\right|} < {\left| \alpha - t\_{n-1}\right|} \right) \land \left( \left(\alpha - t\_n\right)\cdot\left(\alpha - t\_{n-1}\right)>0 \right)
$$
$$
P \equiv \left(\alpha - t\_n\right)\cdot\left(\alpha - t\_{n-1}\right) < {\left(\alpha - t\_{n-1}\right)}^2
$$
Hence if \$P\$ is found to be false the either the target has been found or we have passed it (or never reach it).
[Answer]
# [Ruby](https://www.ruby-lang.org/), 56 bytes
```
f=->a,g,t=1{a==g[t]||(g[2]-g[1])*(g[t]-a)<0&&f[a,g,t+1]}
```
Recursively, checks if current term `g[t] == a`, then return `true`. Else, check if the **product** of difference `g[2] - g[1]` and `a - g[t]` are of opposite sign, if yes, then return `false`
[Try it online!](https://tio.run/##RY7LCoMwFET3/QpX4uNeSFIUKkY/JGRhF4nZlXKFBPXbUx@tXc5hODPv6RliNBK7ASyQ5PMgpVWklyWzSmi0iuu8yHaEQ96yNDXqqJZcr/GVGFUDdn72q779E/4iZ48DiMKj@DKsTsT4VRNVDeN2gsBLDkEKcNsVau89NdS5pB8VQQBfBnDbcHPpT9PuiR8 "Ruby – Try It Online")
---
# [Ruby](https://www.ruby-lang.org/), 40 bytes
*Port of [dingledooper](https://codegolf.stackexchange.com/users/88546/dingledooper)'s [Python answer](https://codegolf.stackexchange.com/a/203008/83605)!*
```
->a,g{(1..(a-g[0]).abs+1).map(&g).any?a}
```
[Try it online!](https://tio.run/##RYxLCsIwFAD3nqIrae17IS/SgsWkBwlZpIt@FkrRCAmhZ4@fal3OMMzt0YXUy4TKwhBzYiy3OGhuCma7e0kFu9g53w8vvIbWLmnOel0DKh/9YnZ/wh8SP32EOHgUX4fVqjhtmahqGCUqB14SBClgkhTd@di6xqkpa0ftIIAvA0wlmWbbr6f3Jz0B "Ruby – Try It Online")
[Answer]
# [Julia](http://julialang.org/), 23 bytes
```
N\~=N∈.~(0:abs(N-~0))
```
[Try it online!](https://tio.run/##dZBNDoIwEIX3PcUsaaSmxaiRiHoCTkBCalIUg4Oh@LNizTm9CIJKBdRdO9@892bmcE5iKW5V5QeF59/LclxY3JVbbfms4JRWEXgQEHJKdRhjrusfAlsBjgTZ6H16hcia2dBiCp4HeXZWBjIxoJFMtCIE1a5nyJD1HFve0RjLyQA/AwmmGDZldVHYujpoVIIvalmnpzuNPsokUVmY7yWGDhdGzzn7WExtGDZ@L1wX/7S9s6J4azXhgEsH1s0lwYVnkQk6ej0cavzmdgN/nGH6Ab0B@FBAqgc "Julia 1.0 – Try It Online")
takes a zero-indexed function as input
port of [dingledooper's solution](https://codegolf.stackexchange.com/a/203008/98541). The solution I found on my own was exactly double the length
]