aboutsummaryrefslogtreecommitdiff
path: root/p99/p03.neb
blob: 05e04578076f7174942ce752f86729be8edb7228 (plain)
1
2
3
4
5
6
7
8
9
10
; P03 - Find the K'th element of a list. 
; The first element in the list is number 1.

(def a (list "a" "b" "c" "d"))

(func kth (lst k)
    (first (slice lst k 1)))  ; since slice returns a list, get the element with first

(print (kth a 3))
;(kth a 8)  ; panic! there is no 8th element