Skip to main content
edited tags
Link
C. K. Young
  • 2.4k
  • 17
  • 23
deleted 36 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I am working my way into learning a bit of Scheme (actually, Racket) with the help of a few practical problems to solve. In this case, I want to split a flat list of symbols at a certain delimiter symbol, discarding it and returning the list of splittedsplit chunks.

So, here is my solution:

itIt does work, but I feel it's not the best way to accomplish the task, for a couple of reasons:

Also, the whole point of this excerciseexercise is learning, so please don't tell me I should use string-split or regex-split or the like. I am aware of their existence.

I am working my way into learning a bit of Scheme (actually, Racket) with the help of a few practical problems to solve. In this case, I want to split a flat list of symbols at a certain delimiter symbol, discarding it and returning the list of splitted chunks.

So, here is my solution:

it does work, but I feel it's not the best way to accomplish the task, for a couple of reasons:

Also, the whole point of this excercise is learning, so please don't tell me I should use string-split or regex-split or the like. I am aware of their existence.

I am working my way into learning a bit of Scheme (actually, Racket) with the help of a few practical problems to solve. In this case, I want to split a flat list of symbols at a certain delimiter symbol, discarding it and returning the list of split chunks.

It does work, but I feel it's not the best way to accomplish the task, for a couple of reasons:

Also, the whole point of this exercise is learning, so please don't tell me I should use string-split or regex-split or the like. I am aware of their existence.

grammar
Source Link
  • The (loop (let (... part seems a bit clunky, maybe even unnecessary.
  • The (list-tail ... clause entails rescanning the list for nextpos elements, which obviously is not optimal. In Python, I would have split-one return the current chunk and a reference to the head of the following, i.e. the cdr of the last element to be considered, and keep iterating from that. Here I'm uncertain at what to do.
  • The (loop (let (... part seems a bit clunky, maybe even unnecessary.
  • The (list-tail ... clause entails rescanning the list for nextpos elements, which obviously is not optimal. In Python, I would have split-one return the current chunk and a reference to the head of the following, i.e. the cdr of the last element to be considered, and keep iterating from that. Here I'm uncertain at what to do.
  • The (loop (let (... part seems a bit clunky, maybe even unnecessary.
  • The (list-tail ... clause entails rescanning the list for nextpos elements, which obviously is not optimal. In Python, I would have split-one return the current chunk and a reference to the head of the following, i.e. the cdr of the last element considered, and keep iterating from that. Here I'm uncertain at what to do.
Source Link
Loading