Giter Club home page Giter Club logo

analysisscript's People

Watchers

 avatar

analysisscript's Issues

Support reference pipe variable and support string interpolation in pipe operation

Summary

Sometimes we want to use values from pipe context in pipe steps, like string interpolation, but hasn't any way to reference current pipe value. Hence, we support reference current value in pipe use '&' keyword and support do string interpolation in pipe operation.

Reference in pipe

Use keyword '&' to reference current value in pipe.

int Add(int left, int right); // register as 'add'
let a = 1
| add &
# a = 2

Stop spread pipe argument

In default, pipe operation will pass the current value of pipe to next function, but in sometimes we don't want to pass current value to next function as first argument, in this case we could use pipe operator '|' again to stop pass first argument to function.

let a = 1
|| add 1 &
# a = 2

String interpolation in pipe (Deprecated)

Just leave literal string to pipe operator

let animal = "fox"

let text = "A lazy"
| "${&} animal"
# text = "A lazy fox"

String interpolation in BFL

Add new method format to BFL to support interpolation.

let a = 1
|| format "${&}"
string Format(string format);
string Format(string ignore, string format);

BFL UT And Sequence BFL functions

  • List<T> ListOf(T sequence)
  • List<T> ListOf(IEnumerable<T> sequence)
  • HashSet<T> SetOf(IEnumerable<T> sequence)
  • HashSet<T> SetOf(T sequence)
  • List<T> Add(List<T> sequence)
  • HashSet<T> Add(HashSet<T> sequence)

Support element sequence

Summary

In practice, we usually define sequence by the [] grammar. But in AnalysisScript we could only generate sequence via a BFL function, like:

let arr = first_item
 # C# signature: List<T> ListOf(T sequence)
| list_of
 # C# signature: List<T> Add(List<T> sequence)
| add second_item
| add third_item

Add the [] grammar to make code more readable.

# typeof(first)[]
let arr = [first, second, third]

let set = arr
 # C# signature: HashSet<T> SetOf(IEnumerable<T> sequence)
| set_of 
 # C# signature: List<T> ListOf(IEnumerable<T> sequence)
| list_of

And add more Collection function to BFL

  • List<T> ListOf(T sequence)
  • List<T> ListOf(IEnumerable<T> sequence)
  • HashSet<T> SetOf(IEnumerable<T> sequence)
  • HashSet<T> SetOf(T sequence)
  • List<T> Add(List<T> sequence)
  • HashSet<T> Add(HashSet<T> sequence)

Support foreach syntax in pipe

Summary

Analysis Script doesn't support any 'foreach' syntax for batch operations. Now we consider add 'foreach' operator '*' follow pipe operator.

int Add(int left, int right) // register as 'add'
# IEnumerable<int> [1,2,3,4]
let result = [1,2,3,4]
|* add 1
| sum

# result = 2+3+4+5
return result

'*' operator will throw exception when last value in pipe does not inherit IEnumerable<T>

let result = [1,2,3,4]
| sum
|* add 1
# throw InvalidOperationException

Support 'IAsyncEnumerable<T>' in pipe operation

Summary

Support IAsyncEnumerable in pipe operation

BFL

Add these functions to support basic operation of async sequence:

  • IAsyncEnumerable<R> SelectAsync<T, R>(IAsyncEnumerable<T> sequence, String property)
  • IAsyncEnumerable<string> FilterContainsAsync(IAsyncEnumerable<string> sequence, string value)
  • IAsyncEnumerable<T> FilterContainsAsync<T>(IAsyncEnumerable<T> sequence, string proeprty, string value)
  • IAsyncEnumerable<T> DistinctAsync<T>(IAsyncEnumerable<T> sequence)
  • IAsyncEnumerable<T> TakeAsync<T>(IAsyncEnumerable<T> sequence, int count)
  • IAsyncEnumerable<T> SkipAsync<T>(IAsyncEnumerable<T> sequence, int count)
  • IAsyncEnumerable<T> LastAsync<T>(IAsyncEnumerable<T> sequence, int count)
  • IAsyncEnumerable<T> FlatAsync<T>(IAsyncEnumerable<IAsyncEnumerable<T>> sequence)
  • Task<string> JoinAsync(IAsyncEnumerable<T> sequence, string delimiter)

Remove 'ui' keyword and use 'call' keyword to instead

Summary

Keyword ui was design to pass variable to UI element:

let logs = 
| ....


ui
| hierarchy_tree_graph logs
| table logs

This is equivalent to method invoke and ui keyword does not implement in latest release version. Thus, we add a new keyword `call to instead of it.

Keyword call

Use call keyword to invoke a method which registered in execution context. Keyword call will ignore return value of method.

let logs =
| ...

call hierarchy_tree_graph logs
call table logs
call write_to_json "logs.json" logs
call notify "https://xxx.com" logs

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.