Re: [Factor-talk] Should we default to main?

2020-12-07 Thread Benjamin Pollack
On Sun, Dec 6, 2020, at 15:44, John Benediktsson wrote:
> We need to figure that out. 
> 
> bi/bi*/bi@
> tri/tri*/tri@
> cleave/spread/apply
> 
> It might make more sense to have a numerical syntax instead of words or 
> better yet would be to only have cleave/spread/apply and have shorter 
> symbolic syntax for it. 
> 
> Plenty of places where [ foo ] keep bar seems to look cleaner than [ foo ] [ 
> bar ] bi and I’d rather we had more consistency and fewer tokens possibly. 

I'm speaking purely for myself, but even to the extent I might agree in the 
narrow case of [ foo ] [ bar ] bi versus [ foo ] keep bar, the relationship 
between bi/bi*/bi@ and tri/tri*/tri@ I think is important, and can cause me to 
lean for bi in many cases even where a keep sequence might arguably be clearer.

That said, if cleave/spread/apply didn't feel so "heavy", I'd definitely be 
fine ditching the bi/tri families in favor of the generics. Your point on 
syntax might work. It also might honestly not feel heavy in practice, even 
today; it'd be interesting to try going a couple weeks using *only* 
cleave/spread/apply directly and see if it actually makes my code worse.___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] How to validate different formats in an array?

2020-12-07 Thread Jon Harper
You can see some solutions for AoC problems on the factor pastebin:
https://paste.factorcode.org/
For day4, there are 2 examples, using 1&& (
https://docs.factorcode.org/content/word-1&&,combinators.short-circuit.html)
or EBNF semantic actions (
https://docs.factorcode.org/content/article-peg.ebnf.semantic-action.html
).
Please add your own :)



Jon

On Mon, Dec 7, 2020 at 5:18 AM Woosuk Kwak  wrote:
>
> Thanks, call(...) is exactly what I needed. And yes, that's the intended 
> stack effect, and 2all? works for my purpose.
>
> It would be helpful if the help page for 'call' mentions 'call(' as an 
> alternative where it doesn't work.
>
> On Mon, Dec 7, 2020, 12:05 PM John Benediktsson  wrote:
>>
>> You should be able to call dynamic quots by specifying their stack effect in 
>> the call, assuming your quotations take one input and produce a Boolean
>>
>> [ call( elt — ? ) ] 2map
>>
>> Or even use 2all? If you want to know if an input array passes all the tests.
>>
>>
>>
>> > On Dec 6, 2020, at 6:11 PM, bubbler9...@gmail.com wrote:
>> >
>> > 
>> > Hi,
>> >
>> > I'm currently solving problems on Advent of Code 2020 
>> > (adventofcode.com/2020) and Rosalind (rosalind.info) in Factor.
>> > I encountered an interesting problem in AoC2020 Day4 Part2: the main part 
>> > of the problem is, given an array of 7 strings, validate them for seven 
>> > different conditions, i.e. test item 0 for condition 0, item 1 for 
>> > condition 1, etc.
>> > I initially thought pushing an array of 7 functions and doing "[ call ] 
>> > 2map" should work, but it didn't. I "solved" the problem by extracting the 
>> > 7 strings on the stack (using "7 firstn"), using spread, and collecting 
>> > them back (using "7 narray"). Is there a better way to achieve this?
>> >
>> > The full code can be found here: 
>> > github.com/Bubbler-4/factor-problem-solving/blob/main/aoc2020/day4/day4.factor
>> > ___
>> > Factor-talk mailing list
>> > Factor-talk@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk


___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk