moonad / Moonad

Moonad: a p2p academic journal, or a social network for code?
http://moonad.org/
MIT License
28 stars 7 forks source link

simplify String.split #38

Closed bukzor closed 4 years ago

bukzor commented 4 years ago

This is an import of what I made before I realized this already existed. Was there some subtle reason for String.split.go to exist?

MaisaMilena commented 4 years ago

String.split.go was just an auxiliary, your solution is much simpler. Can you update the cases to be in a new line? For example:

// Line 8
| true => 
   case using:
   | nil => List.cons<String>(String.cons(xs.head, String.nil), String.split(xs.tail, using));
   | cons => List.cons<String>("", String.split(String.drop(String.length(using), xs), using));
 ;

Also, the ; goes bellow the | that it "closes" or with the last ;. We need a document explaining these conventions.

...
  | case f(xs.head):
    | String.cons(xs.head,String.filter(f, xs.tail));
    | String.filter(f, xs.tail);; <-- here

Also, I didn't know about the use of The for tests, really cool!

MaisaMilena commented 4 years ago

I think we can also improve the using parameter. What do you think about "separator", "sep" or "match"?

VictorTaelin commented 4 years ago

I think it can be simplified a little bit still, probably inspired on List.chunks_of, but looks great. Merging.