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