<commit_before>###
# [source]

.HLL 'Tcl', 'tcl_group'
.namespace

.sub '&lindex'
  .param pmc argv :slurpy
  
  .local int argc 
  argc = argv
  if argc < 1 goto bad_args
  
  .local pmc __list, _list_index
  __list      = get_root_global ['_tcl'], '__list'
  _list_index = get_root_global ['_tcl'], '_list_index'

  .local pmc list
  list = argv[0]
  list = __list(list)

have_list:
  if argc == 1 goto done

select_elem:
  $P0 = argv[1]
  .local pmc indices
  indices = __list($P0)
  
  .local int index
  .local int elems
  elems = indices
  $I0 = 0
select_loop:
  if $I0 >= elems goto done
  list = __list(list)
  
  $P0 = indices[$I0]
  index = _list_index(list, $P0)
  list  = list[index]
  
  inc $I0
  goto select_loop

done:
  .return(list)

bad_args:
  .throw('wrong # args: should be "lindex list ?index...?"')

.end<commit_msg>[tcl]: Make [lindex] work when multiple indices are passed<commit_after>###
# [source]

.HLL 'Tcl', 'tcl_group'
.namespace

.sub '&lindex'
  .param pmc argv :slurpy
  
  .local int argc 
  argc = argv
  if argc < 1 goto bad_args
  
  .local pmc __list, _list_index
  __list      = get_root_global ['_tcl'], '__list'
  _list_index = get_root_global ['_tcl'], '_list_index'

  .local pmc list
  list = argv[0]
  list = __list(list)

have_list:
  if argc == 1 goto done

  $I0 = 0
select_elem:
  inc $I0
  if $I0 == argc goto done

  $P0 = argv[$I0]
  .local pmc indices
  indices = __list($P0)
  
  .local int index
  .local int elems
  elems = elements indices
  $I1 = 0
select_loop:
  if $I1 >= elems goto select_elem
  list = __list(list)
  
  $P0 = indices[$I1]
  index = _list_index(list, $P0)
  list  = list[index]
  
  inc $I1
  goto select_loop

done:
  .return(list)

bad_args:
  .throw('wrong # args: should be "lindex list ?index...?"')
.end
{'fraction_non_alphanumeric': 0.12849162011173185, 'fraction_numerical': 0.01675977653631285, 'mean_word_length': 2.9711751662971175, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4810517', 'n_tokens_mistral': 751, 'n_tokens_neox': 734, 'n_words': 207}