Skip to content

Commit

Permalink
utils: deep-at moved to assocs.extras.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed May 17, 2012
1 parent 0792c2b commit c7dbba2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 34 deletions.
6 changes: 3 additions & 3 deletions facebook/facebook.factor
@@ -1,9 +1,9 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: accessors assocs combinators http.client images.http
json.reader kernel sequences urls urls.encoding urls.secure
utils ;
USING: accessors assocs assocs.extras combinators http.client
images.http json.reader kernel sequences urls urls.encoding
urls.secure utils ;

IN: facebook

Expand Down
6 changes: 3 additions & 3 deletions google/search/search.factor
@@ -1,9 +1,9 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: accessors arrays assocs colors.constants combinators
formatting http.client io io.styles json.reader kernel sequences
urls utils wrap.strings ;
USING: accessors arrays assocs assocs.extras colors.constants
combinators formatting http.client io io.styles json.reader
kernel sequences urls utils wrap.strings ;

IN: google.search

Expand Down
4 changes: 2 additions & 2 deletions google/translate/translate.factor
@@ -1,8 +1,8 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: assocs google http.client io json.reader kernel locals
namespaces sequences urls urls.secure utils ;
USING: assocs assocs.extras google http.client io json.reader
kernel locals namespaces sequences urls urls.secure utils ;

IN: google.translate

Expand Down
3 changes: 2 additions & 1 deletion repopular/repopular.factor
Expand Up @@ -3,7 +3,8 @@

IN: repopular

USING: assocs http.client json.reader kernel sequences utils ;
USING: assocs assocs.extras http.client json.reader kernel
sequences utils ;

: the-yahoo-way ( -- seq )
"http://query.yahooapis.com/v1/public/yql?q=use%20'http%3A%2F%2Fyqlblog.net%2Fsamples%2Fdata.html.cssselect.xml'%20as%20data.html.cssselect%3B%20select%20*%20from%20data.html.cssselect%20where%20url%3D%22repopular.com%22%20and%20css%3D%22div.pad%20a%22&format=json&diagnostics=true&callback="
Expand Down
5 changes: 0 additions & 5 deletions utils/utils-tests.factor
Expand Up @@ -18,11 +18,6 @@ TUPLE: foo a b c ;
[ H{ { "a" 1 } { "b" 2 } { "c" 3 } } foo new [ set-slots ] keep ]
unit-test

[ f ] [ f { } deep-at ] unit-test
[ f ] [ f { "foo" } deep-at ] unit-test
[ f ] [ H{ { "a" H{ { "b" 1 } } } } { "a" "c" } deep-at ] unit-test
[ 1 ] [ H{ { "a" H{ { "b" 1 } } } } { "a" "b" } deep-at ] unit-test

USE: math.statistics

[ { { 1 3 } { "Other" 2 } } ]
Expand Down
20 changes: 0 additions & 20 deletions utils/utils.factor
Expand Up @@ -44,9 +44,6 @@ SYNTAX: INCLUDING: ";" [ (include) ] each-token ;

: of ( assoc key -- value ) swap at ;

: deep-at ( assoc seq -- value/f )
[ swap at ] each ;

USE: math.statistics
USE: sorting

Expand Down Expand Up @@ -74,23 +71,6 @@ USE: assocs.private

USE: grouping

:: longest-subseq ( seq1 seq2 -- subseq )
seq1 length :> len1
seq2 length :> len2
0 :> n!
0 :> end!
len1 1 + [ len2 1 + 0 <array> ] replicate :> table
len1 [1,b] [| x |
len2 [1,b] [| y |
x 1 - seq1 nth
y 1 - seq2 nth = [
y 1 - x 1 - table nth nth 1 + :> len
len y x table nth set-nth
len n > [ len n! x end! ] when
] [ 0 y x table nth set-nth ] if
] each
] each end n - end seq1 subseq ;

: swap-when ( x y quot: ( x -- n ) quot: ( n n -- ? ) -- x' y' )
'[ _ _ 2dup _ bi@ @ [ swap ] when ] call ; inline

Expand Down

0 comments on commit c7dbba2

Please sign in to comment.