Giter Club home page Giter Club logo

Comments (3)

Rohansi avatar Rohansi commented on August 22, 2024

I'm not sure what problem this is meant to solve, could you come up with a better example?

from mond.

SirTony avatar SirTony commented on August 22, 2024

As I mentioned above, it's more niche than problem-solver. Closer to syntax sugar than anything else, mainly allowing an anonymous function or lambda to be separated from the argument list of a function call, which would be most useful for array prototype functions like map, filter, and reduce, which take a callback as their only argument and apply it to each element of the sequence.

Another example could be a slightly more complex filtering algorithm to collect a list of file names.

// List all .cs files in the current directory
// that don't contain pre-processor directives
var files = Directory.getFiles( "./*.cs" ).filter() <|
fun( name ) {
    var lines = File.readAllText( name )         // Read file contents into memory
                    .split( "\n" )               // Split on LF
                    .map( line -> line.trim() ); // Map each line through a lambda
                                                 // that trims all whitespace off both ends

    foreach( var line in lines ) { // Iterate the sanitized lines
        if( line.startsWith( "#" ) )
            return false; // Reject the file if any of the lines start with '#'
    }

    return true; // Otherwise accept the file.
};

from mond.

Rohansi avatar Rohansi commented on August 22, 2024

I'm still not sure about it. The only advantage I see from this is the function call's closing parenthesis can stay with the call. I don't think it's very useful to chain <| either.

If there was a better example for this I'd be up for it, but right now it looks like it only lets you type a bit more to keep the closing parenthesis with the call.

from mond.

Related Issues (20)

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.