Clojure Vectors get

2018-12-21 18:39 更新

返回向量中索引位置處的元素。

語法

以下是get的基本使用語法:

(get vec index)

參數(shù)? 'vec'是向量中的元素集。 'index'是需要返回的索引位置的元素。

返回值 ? 索引位置處的元素值。

面是get函數(shù)的示例:

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (get (vector 3 2 1) 2))
   (println (get (vector 3 2 1) 1)))
(example)

輸出

以上示例將輸出以下結(jié)果:

1
2
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)