but i find it not pleasant to wear the lamba () ... just because it is a convention? or perheaps there is something to understand that i do not see? so i decided to wrote this little macro in the way apply works:
i think it is more simple and readable than the solution with call-with-values but i appreciate to know if i'm wrong or missing something and if it exist other syntax to do it?
You can use (thunk body ...) instead of (lambda () ...) in this case.
It's not convention, though: it's explicitly used to delay evaluation. The call-with-values procedure expects a procedure of 0 arguments that produces multiple values, which are handed to the continuing procedure (second argument). Because Racket does not permit things like (add1 (values 1 2) 3), similarly (call-with-values (values 1 2 3) list) doesn't make sense.
The "extra notation" is not in the way so much with (call-with-values (thunk (f args)) list) (in other words, extracting the computation of the values to a named function; if it's nullary, simply (call-with-values f list)). Depending on your need you could also use define-values, let-values, match/values (and several other match cousins), or Qi.
Syntax: Each element and producer can be any expression.
Semantics: A list/mv expression is evaluated as follows: Each element and producer are evaluated in an unspecified order. A list constructed from the single values of the elements and the multiple values of producer in that order is then returned.
i can avoid define and let , only use define for procedures with Scheme+ , i'm sometimes learn the philosophy of Qi, and search for examples in concrete code, i would be interested in having a solution to this problem (see below) with Qi?
for now i have a text file and read the lines in a vector (tdl),then parse them to generate a 3D point list compatible with plot , those solutions worked :
△ ("separate") and ▽ ("collect") are the standard way to translate between lists and values in Qi.
Note: this solution uses Qi 5 which is in the process of being released this week, specifically this change regarding the "zip" functionality used in your code, so you will need to wait a few days before trying the above solution
Otherwise, if you can't wait, this variant should also work in the currently-released Qi:
oh... i had made an error that i did not corrected online till, if you @countvajhula wrote the Qi code starting from my code? i over-complexified the problem, plot3d take not the arguments of my previous code, the correct code is:
that would be interesting to define Lplot in Qi but tonight i still have not the solution, because my skill in Qi are of beginner, i let you @countvajhula help me.
In the updated version, using a standard for/list comprehension seems like a fine way to do it. But if you want to use higher-order functions instead, here's how you could do it in Qi:
but in Qi my parsing fails because of /t (tabs) that does not appear with Racket classic code , i do not understand,if it is related to Qi or no?
here is a screenshot showing it seems to works in REPL with littteral string but not from code with string get from files, the more strange is that with Racket code and the same library function string-splitit is ok but not when used by Qi
using the (sep flo) is (~> sep (amp flo)) idiom. This version also avoids collecting the result of (amp string->number) into a list only to throw it to list->vector; with Qi, we can just pass all the values to the vector constructor
but i do not understand well why we need 2 ~> ? can not it be done with a global single one ~> ? and is it possible to insert the initial vector->list in the flow?
but i do not understand well why we need 2 ~> ? can not it be done with a global single one ~> ? and is it possible to insert the initial vector->list in the flow?
In this case, the △ form expects a single flow parameter (which could be a use of ~>). But if you like, since Qi is macro-extensible just like Racket, you could define your own variant that implicitly does ~>:
If i understand Qi is working with list , so vector have to be converted in list, perheaps a silly question but isn't it possible to make it works with vectors too ? as it already use values too and perheaps other types...
and this is working with the SRFI-105 curly infix :
but when activating a strict SRFI 105 compatibility mode by setting:
(define srfi-strict #t) ; enable strict compatibility with SRFI 105
in SRFI-105-curly-infix.rkt in the source code of SRFI-105 parser which require to have downloaded the source code , not just installed it via package manager.
If i understand Qi is working with list , so vector have to be converted in list, perheaps a silly question but isn't it possible to make it works with vectors too ? as it already use values too and perheaps other types...
Yeah, making △ work with generic sequences or collections would be quite interesting and coincidentally also came up in today's Qi meetup.
Nice! Although, I'm not sure if it will be easy to express nonlinear flows in infix syntax, for instance, things like == and -<. If you manage to do that I'd be curious to learn about how you do it.
It should be feasible ,if not already done, indeed the infix procedures i wrote are becoming more and more hard. But the real question is that ~> is well describing a flow like an arrow and is well readable and understandable in infix notation for a linear flow but -< is more readable in prefix notation, as the symbol -< represent a graph going in 2 directions only a 2D representation can show it , but the code are written linearly. It is like that, nothing to do i think unless showing it as we already do it in scheme by putting the 2 flow on 2 different lines:
just a question to replace cddddr cdr by vectors (because cdddddr does not exist) i want to use a slicing procedure of my own like this ($bracket-apply$ v 5 :) , $bracket-apply$ is part of SRFI 105 but how can i pass the parameter v which will be the flow (then a vector)? i tried ($bracket-apply$ _ 5 :) but i have an error.