<commit_before>#
# [lrange]
#

.HLL 'Tcl', 'tcl_group'
.namespace

.sub '&lrange'
  .param pmc argv :slurpy  

  # XXX need error handling.

  .local pmc the_list
  the_list = argv[0]
 
  .local pmc first
  first = argv[1]

  .local pmc __index
  __index = get_root_global ['_tcl'], '__index'

  .local pmc __list
  __list = get_root_global ['_tcl'], '__list'
 
  the_list = __list(the_list)

  ($P0,$I2) = __index(first, the_list)
  first = $P0

  .local pmc last
  last = argv[2]

  ($P0,$I2) = __index(last, the_list)
  last = $P0
 
  .local int the_index
  the_index = $P0

  # XXX: Cargo culted comment? There's no splice in this code...

  # XXX workaround, splice doesn't work on TclList <-> TclList.
  # Until that's fixed, manually lrange the list elements
  # This is a hideous hack.

  .local int cnt_in,cnt_out
  cnt_out = 0
  cnt_in = first

  .local pmc retval
  retval = new .TclList
  .local int last_pos
  last_pos = last
LOOP:
  if cnt_in > last_pos goto DONE
  $P1 = the_list[cnt_in]
  retval[cnt_out] = $P1
  inc cnt_in
  inc cnt_out
  goto LOOP
DONE:
  .return (retval)


.end<commit_msg>[tcl] pass a few more [lrange] tests.<commit_after>#
# [lrange]
#

.HLL 'Tcl', 'tcl_group'
.namespace

.sub '&lrange'
  .param pmc argv :slurpy  

  # XXX need error handling.

  .local pmc the_list
  the_list = argv[0]
 
  .local pmc first
  first = argv[1]

  .local pmc __index
  __index = get_root_global ['_tcl'], '__index'

  .local pmc __list
  __list = get_root_global ['_tcl'], '__list'
 
  the_list = __list(the_list)

  ($P0,$I2) = __index(first, the_list)
  first = $P0
  if first >= 0 goto _last
  first = 0

 _last:
  .local pmc last
  last = argv[2]

  ($P0,$I2) = __index(last, the_list)
  last = $P0
 
  .local int the_index
  the_index = $P0

  # XXX: Cargo culted comment? There's no splice in this code...

  # XXX workaround, splice doesn't work on TclList <-> TclList.
  # Until that's fixed, manually lrange the list elements
  # This is a hideous hack.

  .local int cnt_in,cnt_out
  cnt_out = 0
  cnt_in = first

  .local pmc retval
  retval = new .TclList
  .local int last_pos
  last_pos = last
LOOP:
  if cnt_in > last_pos goto DONE
  $P1 = the_list[cnt_in]
  retval[cnt_out] = $P1
  inc cnt_in
  inc cnt_out
  goto LOOP
DONE:
  .return (retval)
.end
{'fraction_non_alphanumeric': 0.11237428946217752, 'fraction_numerical': 0.012243113248797552, 'mean_word_length': 2.993019197207679, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '2387692', 'n_tokens_mistral': 969, 'n_tokens_neox': 926, 'n_words': 275}