@Ingo,
, clojure.lang.PersistentVector clojure Frege.
, PersistentMap , :
module foo.Foo where
[] , ListView , head, tail,...
instance ListView PersistentVector
clojure Frege (pure native Java Frege, - , , , Clojure, ):
data PersistentVector a = native clojure.lang.IPersistentVector where
-- methods needed to create new instances
pure native empty clojure.lang.PersistentVector.EMPTY :: PersistentVector a
pure native cons :: PersistentVector a -> a -> PersistentVector a
-- methods needed to transform instance into Frege list
pure native valAt :: PersistentVector a -> Int -> a
pure native length :: PersistentVector a -> Int
, clojure Frege :
fromList :: [a] -> PersistentVector a
fromList = fold cons empty
toList :: PersistentVector a -> [a]
toList pv = map pv.valAt [0..(pv.length - 1)]
"" ; . @Dierk, .
[EDIT] ListView ( Frege PersistentVector) uncons, null take ( , ):
null :: PersistentVector a -> Bool
null x = x.length == 0
uncons :: PersistentVector a -> Maybe (a, PersistentVector a)
uncons x
| null x = Nothing
-- quick & dirty (using fromList, toList); try to use first and rest from Clojure here
| otherwise = Just (x.valAt 0, fromList $ drop 1 $ toList x)
take :: Int -> PersistentVector a -> PersistentVector a
-- quick and dirty (using fromList, toList); improve this
take n = fromList β’ PreludeList.take n β’ toList
PreludeList.take, take , PersistentVector, fromList, toList, cons empty.
uncons, null take, instance , PersistentVector Frege ). , , :
fromClojure :: PersistentVector a -> PersistentVector a
fromClojure = PersistentVector.fromList β’ myfregefn β’ PersistentVector.toList
-- sample (your function here)
myfregefn :: [a] -> [a]
myfregefn = tail
clojure (foo.Foo/fromClojure [1 2 3 4]) clojure myfregefn ( [2 3 4]). myfregefn , clojure, Frege (String, Long,...), PersistentVector.fromList ( ). , tail, , head , , Long String.
, ', e. . PersistentVector a [a].
: , clojure Frege, " ". , , , Ingo, .