>
> How come "rest" doesn't just use a virtual sequence to offset the
> original index by 1.
>
You're thinking of "rest-slice", which is a virtual version of "rest".
--
Try New Relic Now & We'll Send You this Cool Shirt
Ne
> I'm glad the final version is so elegant!
>
> Best,
> John.
"Chuck Moore declared that the software problem was solved and that
the remaining problem was hardware."
-- http://www.ultratechnology.com/
With the software problem solved, maybe the remaining problems are
hardware and pure math.
-
On Wed, May 22, 2013 at 8:58 AM, John Benediktsson wrote:
> Using ranges, "iota rest" is just "[1,b)" (and more memory efficient because
> rest causes the virtual sequence to become concrete).
How come "rest" doesn't just use a virtual sequence to offset the
original index by 1.
---
Using ranges, "iota rest" is just "[1,b)" (and more memory efficient because
rest causes the virtual sequence to become concrete).
The filter-combinations word is more efficient than all-combinations [ ... ]
filter because it can ignore or skip the ones that are not triples as it builds
the res
wrote:
>> Oo, or even
>>
>>
>> : triples ( n -- seq )
>> iota rest 3 [ first3 triple? ] filter-combinations ;
Out of all the examples given in several languages, this is by far the
most concise version.
--
Try New Re
On Mon, May 20, 2013 at 10:11 PM, Alex Vondrak wrote:
> Oo, or even
>
>
> : triples ( n -- seq )
> iota rest 3 [ first3 triple? ] filter-combinations ;
Does filter-combinations filter as it builds the list?
Or does it build the list then filter it?
---
Oo, or even
: triples ( n -- seq )
iota rest 3 [ first3 triple? ] filter-combinations ;
On Mon, May 20, 2013 at 7:06 PM, Alex Vondrak wrote:
> Or, going by the algorithms in the wiki:
>
> ```
> USING: arrays kernel locals math math.ranges sequences
> sequences.extras ;
>
> :: triples ( n -
Or, going by the algorithms in the wiki:
```
USING: arrays kernel locals math math.ranges sequences
sequences.extras ;
:: triples ( n -- seq )
n [1,b] [| x |
x n [a,b] [| y |
y n [a,b]
[| z | x sq y sq + z sq = ]
[| z | x y z 3array ]
fi
! Copyright (C) 2013 Your name.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences math math.functions arrays math.combinatorics ;
IN: pythagorean-triples
: a-b-list ( n -- seq )
iota rest 2 all-combinations ;
: a-b-c ( seq1 -- seq2 )
[ first ]
[ second ]
We don't have "list comprehensions", per se - but instead have basic map
and filter operations...
Instead of
[ x for x in range(5) if x % 2 == 0 ]
We would have:
5 iota [ 2 mod zero? ] filter
Instead of
[ x ** 3 for x in foo() ]
We would have:
foo [ 3 ^ ] map
You could use
On Sat, Sep 26, 2009 at 8:44 PM, Hugh Aguilar wrote:
> For example, I want to find a node in the list and split the list into two
> lists at that point. With sequences, the function find returns an index into
> the sequence. None of the spliting functions take an index however. All of
> them are s
On Sun, Sep 27, 2009 at 1:44 PM, Hugh Aguilar wrote:
> None of the spliting functions take an index however. All of
> them are splitting on a particular subsequence.
I think you want 'cut' or 'cut*'. This is in the "Subsequences and
Slices" part of the help.
Chris.
--
http://www.bluishcoder.co.
On Fri, May 29, 2009 at 11:03 PM, Hugh Aguilar wrote:
> I'm aware of unit testing, having read about it in a book: "Foundations of
> Agile Python Development" (Jeff Younker). I don't have much experience with
> it in any language though (I'm learning Python simultaneously with learning
> Factor).
Hi Hugh, are you aware of unit testing?
it's very simple and short to write.
In other languages it's sometimes a pain, but here it's very short.
you should try it, instead of the test utils at the end :-)
Kobi
Slava Pestov wrote:
> Hugh,
>
> What you've implemented is like Factor's dlists,
> htt
Hugh,
What you've implemented is like Factor's dlists,
http://docs.factorcode.org/content/article-dlists.html.
They are an implementation of the deque abstract data type,
http://docs.factorcode.org/content/article-deques.html
Slava
On Tue, May 26, 2009 at 11:59 PM, Hugh Aguilar wrote:
> Here i
On Dec 20, 2008, at 11:11 AM, Jose A. Ortega Ruiz wrote:
> I'd like to implement a FUEL command displaying the list of callers
> of a
> given word. Is there an easy way to ask factor for them?
The "usage." word will do what you want.
\ swap usage.
-Joe
---
16 matches
Mail list logo