Aha! How could I rewrite for-all? so that it prints the first stack that
fails the predicate?
Cheers,
Andrew Pennebaker
www.yellosoft.us
On Thu, Aug 25, 2011 at 1:11 AM, Joe Groff arc...@gmail.com wrote:
On Aug 24, 2011, at 10:05 PM, Andrew Pennebaker wrote:
Joe, your for-all? looks
On Aug 25, 2011, at 12:34 AM, Andrew Pennebaker wrote:
Aha! How could I rewrite for-all? so that it prints the first stack that
fails the predicate?
The most straightforward thing I can think of is to package up the generated
values with outputsequence, then feed the array to the predicate
Is there a word more general than firstn? I'd like to push all the elements
of a sequence onto the stack.
Cheers,
Andrew Pennebaker
www.yellosoft.us
On Sun, Aug 21, 2011 at 2:26 PM, Alexander J. Vondrak
ajvond...@csupomona.edu wrote:
first2:
Typically there are better ways to operate on sequences than to put all the
elements on the stack, but you could:
( scratchpad ) { 0 1 2 3 } dup length firstn
Better might be to use some combinators to act on the sequence each grabbing
the element that they need (bi, tri, or the more general
I've got a function that I want to call over a sequence of values (both are
determined at run time).
Is there something like call that accepts a sequence of arguments?
Something like this:
f args call-seq
Cheers,
Andrew Pennebaker
www.yellosoft.us
On Wed, Aug 24, 2011 at 10:04 PM, John
Look at inputsequence from combinators.smart.
On Wed, Aug 24, 2011 at 7:19 PM, Andrew Pennebaker
andrew.penneba...@gmail.com wrote:
I've got a function that I want to call over a sequence of values (both are
determined at run time).
Is there something like call that accepts a sequence of
On Aug 24, 2011, at 6:50 PM, Andrew Pennebaker wrote:
Is there a word more general than firstn? I'd like to push all the elements
of a sequence onto the stack.
Asking for a function that pushes all the elements of an arbitrary sequence
onto the stack is like asking for an [a] - (a,a,a,...)
Thanks, inputsequence seems to be what I'm looking for.
I must be incorrectly declaring and passing the quotations, because I get a
compilation error.
Code at GitHub https://github.com/mcandre/factcheck.
$ ./example.factor
Loading /Users/andrew/.factor-rc
The word for-all cannot be executed
Aye, it's a bit awkward, but I know that Haskell can do it because that's
how Haskell's QuickCheck library works. It even goes one step further and
creates the appropriate list of value generators according to the
predicate's type.
Cheers,
Andrew Pennebaker
www.yellosoft.us
On Wed, Aug 24, 2011
On Aug 24, 2011, at 8:38 PM, Andrew Pennebaker wrote:
$ ./example.factor
Loading /Users/andrew/.factor-rc
The word for-all cannot be executed because it failed to compile
Cannot apply “inputsequence” to an input parameter of a non-inline word
macro inputsequence
inputsequence is also a
On Aug 24, 2011, at 8:44 PM, Andrew Pennebaker wrote:
Aye, it's a bit awkward, but I know that Haskell can do it because that's how
Haskell's QuickCheck library works. It even goes one step further and creates
the appropriate list of value generators according to the predicate's type.
My goal is to test a user-supplied predicate, e.g. even? with a function
for-all that checks even? for all values (actually just 100 random values),
in other words, that arbitrary-integer even? is always true. Obviously this
is not true, but we need a predicate that fails in order to test the test
On Aug 24, 2011, at 9:30 PM, Andrew Pennebaker wrote:
predicate { gen-type1 gen-type2 gen-type3 ... } for-all
The generators needn't be in an array; they could be a simple quotation. Simply
calling each generator function in turn will line up their outputs on the stack
in the proper order.
The exemplar idea is attractive, especially since it's idiomatic in Factor.
However, an exemplar of 1 may not be precise enough for certain predicates.
How can we define sufficiently specific exemplars for predicates like
non-negative? positive? divides-by-three? byte? char? lowercase char?
On Aug 24, 2011, at 9:50 PM, Andrew Pennebaker wrote:
The exemplar idea is attractive, especially since it's idiomatic in Factor.
However, an exemplar of 1 may not be precise enough for certain predicates.
True. Unfortunately Factor doesn't support CLOS-style eq generics, otherwise
you
Joe, your for-all? looks promising (and it's incredibly short). However,
when I try it, I'm still getting that macro error.
Latest code incorporating your for-all?:
https://github.com/mcandre/factcheck
Macro Error:
$ ./example.factor
Loading /Users/andrew/.factor-rc
The word main cannot be
first2: http://docs.factorcode.org/content/word-first2,sequences.html
In general, firstn:
http://docs.factorcode.org/content/word-firstn,sequences.generalizations.html
Regards,
--Alex Vondrak
From: Andrew Pennebaker [andrew.penneba...@gmail.com]
Sent:
Also, for your case a sequence of two elements can be treated a bit like a map
of key/value pairs. You can use the assocs vocabulary to manipulate your
sequence (called an association list or 'alist' in the documentation).
Try:
( scratchpad ) USE: assocs
( scratchpad ) \ assoc-map help
(
18 matches
Mail list logo