]> gitweb.factorcode.org Git - factor.git/commitdiff
kernel: add transmute and some use cases
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 25 Feb 2023 23:46:53 +0000 (17:46 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 26 Feb 2023 23:11:05 +0000 (17:11 -0600)
basis/alien/libraries/finder/finder.factor
basis/unix/linux/proc/proc.factor
core/kernel/kernel.factor
extra/mediawiki/api/api.factor

index 876880608d323f5a2370446d2d0ab47533288779..0a16dea39076f37af54a1830806053e238510e27 100644 (file)
@@ -1,11 +1,10 @@
-USING: accessors alien.libraries kernel sequences system vocabs
-;
+USING: accessors alien.libraries kernel sequences system vocabs ;
 IN: alien.libraries.finder
 
 HOOK: find-library* os ( name -- path/f )
 
 : find-library ( name -- path/library-not-found )
-    dup find-library* [ nip ] when* ;
+    [ find-library* ] transmute ;
 
 : ?update-library ( name path abi -- )
     pick lookup-library [ dll>> dll-valid? ] [ f ] if* [
index dc7512d9f63655d49042216778beea6497e55674..ff0282b0790c9db5554112e17ea80257e0cef0f5 100644 (file)
@@ -336,5 +336,5 @@ TUPLE: pid-stat pid filename state parent-pid group-id session-id terminal#
     proc-first-line
     split-words harvest
     pid-stat "slots" word-prop length "0" pad-tail
-    [ dup string>number [ nip ] when* ] map
+    [ [ string>number ] transmute ] map
     [ pid-stat boa ] input<sequence ;
index c9b19c3cfbff142dfb85e838d725671ce0dd4610..29579b977aa62e9f8a83f5df68430ed8fa9d6340 100644 (file)
@@ -173,19 +173,22 @@ DEFER: if
 
 : ?call ( ..a obj/f quot: ( ..a obj -- ..a obj' )  -- ..a obj'/f ) dupd when ; inline
 
-: transmute ( old quot: ( old -- new/f ) -- new/old new? )
+: ?transmute ( old quot: ( old -- new/f ) -- new/old new? )
     keep over [ drop t ] [ nip f ] if ; inline
 
+: transmute ( old quot: ( old -- new/f ) -- new/old )
+    ?transmute drop ; inline
+
 ! Default
 
 : ?when ( ..a default cond: ( ..a default -- ..a new/f ) true: ( ..a new -- ..b ) -- ..b )
-    [ transmute ] dip when ; inline
+    [ ?transmute ] dip when ; inline
 
 : ?unless ( ..a default cond: ( ..a default -- ..a new/f ) false: ( ..a default -- ..b ) -- ..b )
-    [ transmute ] dip unless ; inline
+    [ ?transmute ] dip unless ; inline
 
 : ?if ( ..a default cond: ( default -- new/f ) true: ( ..a new -- ..b ) false: ( ..a default -- ..b ) -- ..b )
-    [ transmute ] 2dip if ; inline
+    [ ?transmute ] 2dip if ; inline
 
 ! Cleavers
 : bi ( x p q -- )
index d6bf666db75768809e5929c4627011a137d153e4..e89fc58e84dd5301d5e5175b8a5a0ec736800b2d 100644 (file)
@@ -147,7 +147,7 @@ PRIVATE>
 
 :: (query) ( params -- obj assoc )
     { { "action" "query" } } params assoc-union api-call dup
-    dup "query" of [ nip ] when*
+    [ "query" of ] transmute
     "siprop" params key? [
         params { "prop" "list" "meta" } values-of sift first of
     ] unless swap ;