f# for 循环继续

时间:2021-06-01 12:39:18

标签: for-loop f# f#-interactive

我希望在 import { RDSClient, DescribeDBInstancesCommand } from "@aws-sdk/client-rds"; import { CognitoIdentityClient, GetIdCommand , GetOpenIdTokenCommand } from "@aws-sdk/client-cognito-identity"; import { getDefaultRoleAssumerWithWebIdentity } from "@aws-sdk/client-sts"; import { fromWebToken } from "@aws-sdk/credential-provider-web-identity"; const region = "us-east-1"; const cognitoClient = new CognitoIdentityClient({ region }) // see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-rds/index.html export default async function getDbInstances() { const { Token, IdentityId } = await getTokenUsingBasicFlow(); const client = new RDSClient({ region, credentials: fromWebToken({ roleArn: "arn:aws:iam::(account id):role/Cognito_RDSDataAppPoolUnauth_Role", webIdentityToken: Token, roleSessionName: IdentityId.substring(IdentityId.indexOf(":") + 1), roleAssumerWithWebIdentity: getDefaultRoleAssumerWithWebIdentity() }) }); const command = new DescribeDBInstancesCommand({}); return (await client.send(command)).DBInstances; } async function getTokenUsingBasicFlow() { const getIdCommand = new GetIdCommand({ IdentityPoolId: "us-east-1:(identity pool id)" }); const id = (await cognitoClient.send(getIdCommand)).IdentityId; const getOpenIdTokenCommand = new GetOpenIdTokenCommand({ IdentityId: id }); return await cognitoClient.send(getOpenIdTokenCommand); } 之后循环继续,所以列表将被填充,然后返回列表

$requestFiltered = Arr::where($request, function($value){ 
    if(is_array($value)){
        return $value;
    }
});

1 个答案:

答案 0 :(得分:4)

这对 list comprehension 来说是个好情况:

let biggestPoliProduct (range: list<int>) =
    [
        for i in range do
            for j in range do
                if isPoli (i * j) then
                    yield (i * j)
    ]

不需要 else 分支。