Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add function that randomises the strings in a string list #64

Open
Assignees
delphidabbler
Labels
acceptedIssue will be actionedenhancementNew feature or request
@delphidabbler

Description

@delphidabbler

Such a function was suggested by@Thaddy in#28 (comment).

A series of overloaded functions, something like the following might do the job (written off the top of my head - not compiled or tested 🤞):

procedureRandomiseStrings(const AList: TStringList); overload;begin  AList.CustomSort(    function(L: TStringList; A, B: Integer): Integerbegin// becomes -1, 0 or 1      Result := Random(3) -1;end   );end;

and a string array version:

functionRandomiseStrings(const AArray:arrayof string): TArray<string>; overload;beginvar SL := TStringList.Create;tryforvar Sin AArraydo      SL.Add(S);    RandomiseStrings(SL);    Result := SL.ToStringArray;finally    SL.Free;end;end;

It's a shame thatTStrings doesn't implementCustomSort - it would have made the routine more general.

Maybe:

procedureRandomiseStrings(const AList: TStrings); overload;beginvar SL := TStringList.Create;try    SL.Assign(AList);    RandomiseStrings(SL);    AList.Assign(SL);finally    SL.Free;end;end;

Metadata

Metadata

Assignees

Labels

acceptedIssue will be actionedenhancementNew feature or request

Projects

Status

Accepted

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp