GithubHelp home page GithubHelp logo

nim-iterutils's People

Contributors

def- avatar metagn avatar ringabout avatar rustomax avatar timotheecour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nim-iterutils's Issues

You have won a FREE new documentation website!

Congratulations!!!

The GitHub(notreally) team has awarded you with the needed website of the week. If you want to win a lot of FAME and rock EVERYWHERE you go, please follow these steps to claim your new and FREE documentation website:

  • Install gh_nimrod_doc_pages typing babel install gh_nimrod_doc_pages.
  • $ cd path/to/your/git/checkout
  • $ git checkout --orphan gh-pages
  • $ git rm -rf .
  • $ gh_nimrod_doc_pages -b
  • Modify the gh_nimrod_doc_pages.ini file to contain the following lines:
["gh-pages"]
update_html=index.html
doc_dir=docs
branches="master"
  • $ gh_nimrod_doc_pages -c .
  • $ git add . && git commit -v
  • $ git push --set-upstream origin gh-pages

Enjoy your new FREE website for your project at http://def-.github.io/iterutils/!!!

Disclaimers:

  • FREE website offer valid only until stocks last.
  • AWESOME prize instructions only verified under MacOSX.
  • Project URL addresses not available at the moment.

SIGSEGV: Illegal storage access

> nim c iterutils.nim
Hint: system [Processing]
Hint: iterutils [Processing]
....
Hint: parseutils [Processing]
SIGSEGV: Illegal storage access. (Try to compile with -d:useSysAssert -d:useGcAssert for details.)

Got here from your informative blog http://hookrace.net/blog/nim-adventures/
Tried to compile but can't. Compiler is v0.10.2.

Implement take method

Does it make sense to add the take method that returns the first n items in an iterator? Here is a rough idea:

import iterutils

iterator take[T](i: Iterable[T], n: Natural): T =
  let i = toIter(i)
  var pos = 0
  for x in i():
    if pos < n:
      yield x
    inc pos

for x in (1..10).take(5): # Output: 1 2 3 4 5
  stdout.write ($x & " ")
echo ""

for x in (1..4).take(5): # number to take is < total iterator members
                         # (should output the whole original iterator: 1 2 3 4)
  stdout.write ($x & " ")
echo ""

for x in (1..10).take(0): # number to take is 0
                          # (should return an empty iterator)
  stdout.write ($x & " ")
echo ""

discard """
for x in (1..10).take(-5): # number to take is negative
                           # (should fail to compile)
  stdout.write ($x & " ")
echo ""
"""

Concat and walkDir don't work together.

Concat works for other iterators like in your tests, but does not work with walkDir, I don't understand why:

import os, iterutils

# works
for n in concat(toIter(1..4), toIter(20..23)):
  echo n

# does not work
for f in concat(walkDir("."), walkDir(".")):
  echo f

I don't understand the error either:

C:\p\try\iterwalkdir.nim(6, 31) Error: attempting to call routine: 'walkDir'
  found 'os.walkDir(dir: string, relative: bool, checkDir: bool) [declared in C:\Users\me\.choosenim\toolchains\nim-1.4.6\lib\pure\os.nim(2076, 10)]' of kind 'iterator

Maybe you can help?

example in https://hookrace.net/nim-iterutils/iterutils.html broken

#test.nim

import iterutils
from sequtils import toSeq
import sugar

proc test1()=
  for i in filter(map(filter(2..10, proc(x: int): bool = x mod 2 == 0),
           proc(x: int): int = x * 2), proc(x: int): bool = x mod 8 == 0):
    echo i

  var s = toSeq (2..10).filter(proc(x): bool = x mod 2 == 0).
      map(proc(x): int = x * 2).filter(proc(x): bool = x mod 8 == 0)
  echo s

  var a = (2..10).filter(proc(x: int): bool = x mod 2 == 0)
  var b = a.map((x: int) => x * 2)
  for i in b.map((x: int) => x + 2):
    echo i
test1()

gives:
test.nim(19, 17) Error: invalid indentation

fixing that gives other errors, and nothing prints

This example should be a test file in this repo so others can fix it (ideally something ran by nimble test iterutils)

links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.