The first one is quite close actually. Besides the comprehension, there is the 
change `math.pi` -> `math.Pi` and `complex` -> `Complex`.
    
    
    import std/[complex, sugar, math]
    
    proc fft(input: seq[Complex[float]]): seq[Complex[float]] =
      let n = input.len
      if n == 1:
        return input
      var even = collect(for i in countup(0, n-1, 2): input[i])
      var odd = collect(for i in countup(1, n-1, 2): input[i])
      var y = fft(even) & fft(odd)
      for k in 0 ..< n div 2:
        let t = y[k]
        let angle = -2.0 * math.Pi * (k / n)
        let u = y[k + n div 2] * exp(complex(0.0, angle))
        y[k] = t + u
        y[k + n div 2] = t - u
      return y
    
    
    Run

The second example is stranger. There is no such API in `std/htmlparser` (it 
would simply be `htmlparser.parseHtml(string)`), there is something similar in 
`std/xmlparser` but it would need a significant rewrite at first glance.

Reply via email to