bgnori / broom

golang practice.
1 stars 0 forks source link

slice操作のためのmacro #29

Open bgnori opened 10 years ago

bgnori commented 10 years ago

appendとかその辺.

これは辛すぎる. srfi-1 (schemeの標準lispライブラリ仕様)も参考にすること

(define my-slice-type (. reflect SliceOf
                       (. reflect TypeByKind (. reflect Int))))

(println my-slice-type)
(define xs (. reflect MakeSlice my-slice-type 0 0))

(let [ys (. reflect Append xs (. reflect ValueOf 1))]
    (println (. ys Len))
    (println (. (. ys Index 0) Interface)))

(let [ys (. reflect Append
            (. reflect Append 
               (. reflect Append 
                  xs 
                  (. reflect ValueOf 1))
               (. reflect ValueOf 2))
            (. reflect ValueOf 3))
      zs (. ys Slice 1 3)
      as (. reflect AppendSlice ys zs)
      ]
    (println (. (. zs Index 0) Interface))
    (println (. zs Len))
    (println (. as Len))
    )
bgnori commented 10 years ago

slice-zip1, slice-zip2とかの返り値に用いるコンテナはどうするのか.

bgnori commented 10 years ago

ClojureでいうところのISeq的なものがほしい