Using prolog,
conc(L1, L2, L3) :- append(L1, L2, L3).
one_after_first(L, Y) :- conc([_ | [Y | []]], _, L).
This solution uses conc
, but there is an easier solution:
one_after_first([_ | [Y | _]], Y).
You can call it with:
one_after_first([1,2,3,4], 2).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.