Code Monkey home page Code Monkey logo

ltk-te's Introduction

LTK-TE

This repository contains a function that adds the numbers at each line of a file including sub files.

Usage

Prerequisite

To run this project, make sure you are using:

  • Python 3
  • Any version of Go

Go

Function usage

Here is a simple example of usage for the function:

package main

import "tlk"

func main() {
  total, err := ltk.AddRec(args[1])
  if err != nil {
    panic(err)
  }
  fmt.Printf("Full total is %d\n", total)
}

Program from binary

Binaries are available for the following platform:

  • MacOS 64-bit
  • Linux 64-bit
  • Windows 64-bit

Build from source

To build from source you need go installed and then you can run the Makefile:

$ > make
GOOS=darwin GOARCH=amd64 go build -o ./bin/sums_darwin_amd64
GOOS=windows GOARCH=amd64 go build -o ./bin/sums_win_amd64.exe
GOOS=linux GOARCH=amd64 go build -o ./bin/sums_linux_amd64

Run tests

To run the tests you can use the Makefile:

$ > make test
=== RUN   TestAddRec
Subtotal for file <some_path>/tests/test_set/d.txt is 6
Subtotal for file <some_path>/tests/test_set/e.txt is 22
Subtotal for file <some_path>/tests/test_set/b.txt is 78
Subtotal for file <some_path>/tests/test_set/e.txt is 22
Subtotal for file <some_path>/tests/test_set/c.txt is 15
Subtotal for file <some_path>/tests/test_set/a.txt is 78
--- PASS: TestAddRec (0.00s)
    sums_test.go:17: Total is 221
=== RUN   TestAddRecSimple
Subtotal for file <some_path>/tests/test_set_simple/b.txt is 5
Subtotal for file <some_path>/tests/test_set_simple/a.txt is 5
--- PASS: TestAddRecSimple (0.00s)
    sums_test.go:28: Total is 10
=== RUN   TestAddRecLoopSimple
--- PASS: TestAddRecLoopSimple (0.00s)
    sums_test.go:24: Recursive loop: <some_path>/tests/test_set_loop_simple/a.txt previously called
PASS

Python

Function usage

Here is a simple example of usage for the function:

from tlk import sum, RecursiveLoopException

def someOtherFunction():
  try:
    total = sum('/path/to/text/file')
  except RecursiveLoopException as e:
    raise e

  print('Total is {:d}'.format(total))

Run tests

To run the tests you can use run:

$ > ./tlk_test.py

The output should be the following:

Subtotal for tests/test_set_loop_complex/d.txt is 6
Subtotal for tests/test_set/d.txt is 6
Subtotal for tests/test_set/e.txt is 22
Subtotal for tests/test_set/b.txt is 78
Subtotal for tests/test_set/e.txt is 22
Subtotal for tests/test_set/c.txt is 15
Subtotal for tests/test_set/a.txt is 78
Subtotal for tests/test_set_simple/b.txt is 5
Subtotal for tests/test_set_simple/a.txt is 5
...
----------------------------------------------------------------------
Ran 3 tests in 0.003s

OK

ltk-te's People

Contributors

ganitzsh avatar

Watchers

 avatar  avatar  avatar

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.