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

Commit8a198b0

Browse files
remove List.take from illib.fs and replace its usages with List.truncate
1 parent9e379d9 commit8a198b0

File tree

10 files changed

+16
-27
lines changed

10 files changed

+16
-27
lines changed

‎src/absil/illib.fs‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,11 @@ module List =
279279
|[]-> None
280280
| h::t->if f hthen Some(h,n)else findi(n+1) f t
281281

282-
283-
lettake n l=
284-
if n= List.length lthen lelse
285-
let recloop acc n l=
286-
match lwith
287-
|[]-> List.rev acc
288-
| x::xs->if n<=0then List.rev accelse loop(x::acc)(n-1) xs
289-
290-
loop[] n l
291-
292282
let recdrop n l=
293283
match lwith
294284
|[]->[]
295285
|_::xs->if n=0then lelse drop(n-1) xs
296286

297-
298287
letsplitChoose select l=
299288
let recch acc1 acc2 l=
300289
match lwith

‎src/fsharp/DetupleArgs.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ let zipCallPatternArgTys m g (callPattern : TupleStructure list) (vss : Val list
511511
lettys= List.collect snd tstys// link fringes
512512
tss, tys
513513

514-
letvss= List.take callPattern.Length vss// drop excessive tys if callPattern shorter
514+
letvss= List.truncate callPattern.Length vss// drop excessive tys if callPattern shorter
515515
lettstys= List.map2(fun ts vs->letts,tyfringe= zipTSTyp ts(typeOfLambdaArg m vs)in ts,(tyfringe, vs)) callPattern vss
516516
List.unzip tstys
517517

@@ -561,16 +561,16 @@ let decideTransform g z v callPatterns (m, tps, vss:Val list list, rty) =
561561
(* NOTE: 'a in arg types may have been instanced at different tuples...*)
562562
(* commonCallPattern has to handle those cases.*)
563563
letcallPattern= commonCallPattern callPatterns// common CallPattern
564-
letcallPattern= List.take vss.Length callPattern// restricted to max nArgs
564+
letcallPattern= List.truncate vss.Length callPattern// restricted to max nArgs
565565
// Get formal callPattern by defn usage of formals
566566
letformalCallPattern= decideFormalSuggestedCP g z tys vss
567-
letcallPattern= List.take callPattern.Length formalCallPattern
567+
letcallPattern= List.truncate callPattern.Length formalCallPattern
568568
// Zip with information about known args
569569
letcallPattern,tyfringes= zipCallPatternArgTys m g callPattern vss
570570
// Drop trivial tail AND
571571
letcallPattern= minimalCallPattern callPattern
572572
// Shorten tyfringes (zippable)
573-
lettyfringes= List.take callPattern.Length tyfringes
573+
lettyfringes= List.truncate callPattern.Length tyfringes
574574
if isTrivialCP callPatternthen
575575
None// no transform
576576
else
@@ -790,7 +790,7 @@ let passBind penv (TBind(fOrig, repr, letSeqPtOpt) as bind) =
790790
letp= transformedFormals.Length
791791
if(vss.Length< p)then internalError"passBinds: |vss|<p - detuple pass"
792792
letxqNs= List.drop p vss
793-
letx1ps= List.take p vss
793+
letx1ps= List.truncate p vss
794794
lety1Ps= List.concat(List.map2 transFormal transformedFormals x1ps)
795795
letformals= y1Ps@ xqNs
796796
// fCBody - parts

‎src/fsharp/NameResolution.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3171,7 +3171,7 @@ let ComputeItemRange wholem (lid: Ident list) rest =
31713171
match restwith
31723172
|[]-> wholem
31733173
|_->
3174-
letids= List.take(max0(lid.Length- rest.Length)) lid
3174+
letids= List.truncate(max0(lid.Length- rest.Length)) lid
31753175
match idswith
31763176
|[]-> wholem
31773177
|_-> rangeOfLid ids

‎src/fsharp/NicePrint.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module private PrintIL =
170170
match System.Int32.TryParse(rightMost, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture)with
171171
|true, n-> n
172172
|false,_->0// looks like it's non-generic
173-
ilTyparSubst|> List.rev|> List.take numParms|> List.rev
173+
ilTyparSubst|> List.rev|> List.truncate numParms|> List.rev
174174

175175
let reclayoutILType(denv:DisplayEnv)(ilTyparSubst:layout list)(typ:ILType):layout=
176176
match typwith

‎src/fsharp/Optimizer.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ and OptimizeApplication cenv env (f0, f0ty, tyargs, args, m) =
25902590
letnDetupArgsL= detupArgsL.Length
25912591
letnShapes= min nargs nDetupArgsL
25922592
letdetupArgsShapesL=
2593-
List.take nShapes detupArgsL
2593+
List.truncate nShapes detupArgsL
25942594
|> List.map(fun detupArgs->
25952595
match detupArgswith
25962596
|[]|[_]-> UnknownValue

‎src/fsharp/QuotationTranslator.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
261261
// Check to see if there aren't enough arguments or if there is a tuple-arity mismatch
262262
// If so, adjust and try again
263263
if curriedArgs.Length< curriedArgInfos.Length||
264-
((List.take curriedArgInfos.Length curriedArgs,curriedArgInfos)||> List.exists2(fun arg argInfo->
264+
((List.truncate curriedArgInfos.Length curriedArgs,curriedArgInfos)||> List.exists2(fun arg argInfo->
265265
(argInfo.Length>(tryDestRefTupleExpr arg).Length)))
266266
then
267267
if verboseCReflectthen

‎src/fsharp/SignatureConformance.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =
239239
elifnot(sigArgInfos.Length<= implArgInfos.Length&& List.forall2(fun x y-> List.length x<= List.length y) sigArgInfos(List.truncate sigArgInfos.Length implArgInfos))then
240240
err(fun(x,y,z)-> FSComp.SR.ValueNotContainedMutabilityAritiesDiffer(x, y, z, id.idText, string sigArgInfos.Length, id.idText, id.idText))
241241
else
242-
letimplArgInfos= implArgInfos|> List.take sigArgInfos.Length
243-
letimplArgInfos=(implArgInfos, sigArgInfos)||> List.map2(fun l1 l2-> l1|> List.take l2.Length)
242+
letimplArgInfos= implArgInfos|> List.truncate sigArgInfos.Length
243+
letimplArgInfos=(implArgInfos, sigArgInfos)||> List.map2(fun l1 l2-> l1|> List.truncate l2.Length)
244244
// Propagate some information signature to implementation.
245245

246246
// Check the attributes on each argument, and update the ValReprInfo for

‎src/fsharp/TypeChecker.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,7 +4991,7 @@ and TcNestedTypeApplication cenv newOk checkCxs occ env tpenv mWholeTypeApp typ
49914991
if not (isAppTy cenv.g typ) then error(Error(FSComp.SR.tcTypeHasNoNestedTypes(), mWholeTypeApp))
49924992
match typ with
49934993
| TType_app(tcref, tinst) ->
4994-
let pathTypeArgs = List.take (max (tinst.Length - tcref.Typars(mWholeTypeApp).Length) 0) tinst
4994+
let pathTypeArgs = List.truncate (max (tinst.Length - tcref.Typars(mWholeTypeApp).Length) 0) tinst
49954995
TcTypeApp cenv newOk checkCxs occ env tpenv mWholeTypeApp tcref pathTypeArgs tyargs
49964996
| _ -> error(InternalError("TcNestedTypeApplication: expected type application", mWholeTypeApp))
49974997

@@ -5273,7 +5273,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
52735273
let args = match args with SynConstructorArgs.Pats args -> args | _ -> failwith "impossible: active patterns can be used only with SynConstructorArgs.Pats"
52745274
let e =
52755275
if dotms.Length = longId.Length then
5276-
let e = SynExpr.LongIdent(false, LongIdentWithDots(longId, List.take (dotms.Length - 1) dotms), None, m)
5276+
let e = SynExpr.LongIdent(false, LongIdentWithDots(longId, List.truncate (dotms.Length - 1) dotms), None, m)
52775277
SynExpr.DiscardAfterMissingQualificationAfterDot(e, unionRanges e.Range (List.last dotms))
52785278
else SynExpr.LongIdent(false, lidwd, None, m)
52795279
List.fold (fun f x -> mkSynApp1 f (convSynPatToSynExpr x) m) e args
@@ -13690,7 +13690,7 @@ module MutRecBindingChecking =
1369013690
let thisValOpt = GetInstanceMemberThisVariable (v, x)
1369113691

1369213692
// Members have at least as many type parameters as the enclosing class. Just grab the type variables for the type.
13693-
let thisTyInst = List.map mkTyparTy (List.take (tcref.Typars(v.Range).Length) v.Typars)
13693+
let thisTyInst = List.map mkTyparTy (List.truncate (tcref.Typars(v.Range).Length) v.Typars)
1369413694

1369513695
let x = localReps.FixupIncrClassExprPhase2C cenv thisValOpt safeStaticInitInfo thisTyInst x
1369613696

‎src/fsharp/ast.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ type LongIdentWithDots =
176176
| LongIdentWithDots([],_)-> failwith"rangeOfLidwd"
177177
| LongIdentWithDots([id],_)-> id.idRange
178178
| LongIdentWithDots(h::t,dotms)->
179-
letnonExtraDots=if dotms.Length= t.Lengththen dotmselse List.take t.Length dotms
179+
letnonExtraDots=if dotms.Length= t.Lengththen dotmselse List.truncate t.Length dotms
180180
unionRanges h.idRange(List.last t).idRange|> unionRanges(List.last nonExtraDots)
181181

182182
//------------------------------------------------------------------------

‎src/fsharp/symbols/Exprs.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ module FSharpExprConvert =
422422
// Check to see if there aren't enough arguments or if there is a tuple-arity mismatch
423423
// If so, adjust and try again
424424
if curriedArgs.Length< curriedArgInfos.Length||
425-
((List.take curriedArgInfos.Length curriedArgs, curriedArgInfos)||> List.exists2(fun arg argInfo->(argInfo.Length>(tryDestRefTupleExpr arg).Length)))then
425+
((List.truncate curriedArgInfos.Length curriedArgs, curriedArgInfos)||> List.exists2(fun arg argInfo->(argInfo.Length>(tryDestRefTupleExpr arg).Length)))then
426426

427427
// Too few arguments or incorrect tupling? Convert to a lambda and beta-reduce the
428428
// partially applied arguments to 'let' bindings

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp