• Does Haskell use unification - like prolog?

    From Ryahow@21:1/5 to All on Mon Nov 14 16:46:02 2016
    What's the reason for the need to Curry [have only single arg functions]?
    Is it for <impedance matching> any input to any output, to make piping easy?
    No ! Because different functions have different in & out types.

    Simple imperative languages, like PASCAL: "reduce" expressions to a term.
    eg. (4 < 3) OR (3 < 4) = NOT (True)
    apparently reduces to the boolean: False;
    and the implementation via the stack-based P-code is simple.

    So what? Can reducing expressions cover general programming?
    Well let's try some: calculate the surface of a sphere of size X;
    is solved by mere expression evaluation.

    The Name of the file in Directory, which has the most count of
    <StringN>.
    Thinking imperatively, ie. HOW TO:
    Get the Directory;
    FORALL Files
    Scan & count <StringN>
    and Accumulate count, for later comparison or just keep the biggest
    ....

    But how does expression-evaluation ONLY, solve this task,
    where the answer's type = FileName?



    --------------= Posted using GrabIt =----------------
    ------= Binary Usenet downloading made easy =---------
    -= Get GrabIt for free from http://www.shemes.com/ =-

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ducnhatphung@gmail.com@21:1/5 to All on Mon Jan 30 02:54:03 2017
    currying function is a part of lazy evaluation in evaluation strategies, it make your program easier to optimize and it benefits in some infinity structure.

    in functional programming, we focus on removing as much side effect as possible so it's quite hard to deal with some io stuff. but, it's not impossible, researchers spends years to solve this problem not to let it go nowhere. so just keep calm, you may
    want to know about `monad`. it's some kind of value wrapper that keep the program flow go right way (Something you may found stupid in C or C++ IO). F# and Elm, some others modern functional programming is using some of these techniques too. just find
    your own way through. There are plenty of document now.

    about reading file, it's simple. why don't you try this?

    ```haskell
    module Main where

    import System.Directory

    main = _dir "C:/"

    _dir _path = do
    setCurrentDirectory _path
    _cd <- getCurrentDirectory
    print _cd
    _file <- getDirectoryContents _cd
    print _file
    ```

    ```haskell
    module Main where

    import System.IO

    main = do
    print <- "Filename:"
    filename <- getLine
    fileData <- readFile filename
    print fileData
    ```

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)