Bill Allombert on Sun, 14 Jan 2024 17:36:31 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: New GP function mapapply
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Sun, 14 Jan 2024 17:36:16 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1705250181; c=relaxed/relaxed; bh=hdGGCLpSWw33+58uDRZO7aa/3hovjEqKLF47Rbv1Tg0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: MIME-Version:Content-Type:Content-Disposition; b=seGfUDOKFK5bMqKRwY3lBBXL0DER57J48RoHceboF3QqMBgguHbuoLJ2npFvqUeJ+hAhgKqXktg6DWm49wZmgqSAGd2lyMMq2XqUf5/TKSWr2FtFvN12pba6PWCTPWR0tAk5YwTTk5jLVHoJFb6Y35BytNQL9rj/2UwllMqjCvRFNRc9r9oJvrLE/lUTZTkqbMs/4k0Gxe74z9MGrVIvFA5B+okoAlvEogZit6DxL8oai9w2XdnaPJIaWP9peQuXljXdcXDGn+1nVK1FOZ8yPe1w628MvP70Sv3wxRgZ1C4HSvdr5sr+Svf2fdYtADPjpQUXJ8u6wqBVDrQu9F2RZSZWHPnmMltO7sJZp/j5H813waHT1/f15ywixehYj4QRT2TYmfswFpKo0mqIP94g69MXfmJUfjpVz2H2FAylm+1RNGCy0tNNDqqZNyAfnW2NTOtuAuhLOqQNJMOZMnxwEYfFw2+1X2WLozYYZLvBB84Yb26v3sDV6NYISJ92DuafcSzfTVXxcnWFVXrGQazxq3F5yI+B1Rg5cqqnlK1io0IAlXnTtwLle8dG5f+mqnS93xBL8Yxrn2lR6pneZMbBToVOd2mI02wP/8NerMvmtS+gG10SNW8/DDAC4Goi/Odv1CGqnkoAihvv73EPIbLC0hgzFzYU+pmygOVkPsssyo4=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1705250181; cv=none; b=QAhksoBbUANq1auJRRXlHvqV1/p5zGf2mt0vsXH1P9Xra9i77IvYCTLkya+t8VTMGFe8EFc4vqd07Xwpbjc9edj9TsZdroVVoe4zVuGTQgYR6B6lD3fbsy0fY2fLs/cgdpapHn03mUW04XH7aDvvwxKixESX3ysxzv0J8qvC6K+JEH6YNR0dF3b98UPsepFtowWzEFrL9JbOnvNt1CyxND3HN0XGkSWkF34c8KDDhgPy/VLM6ml2KRVsbRgnxyfkdjJK5yq2KS4WfZHu5tSD1n6JFdIZ6+WK3C7qr5unEWLd5MVKIrNNXC2kIjNz1X4XejSvglVhbgYKmb/GSX9EXB6kHRAcrRgBRuBtfBzl4IdmRJnr7L4MwdBY+dT87iJZQUC9WW/4nzi8YiTJPKQ2pvOLQy2aJaDFfSoL+r6qlPRoD4PLlcJluoEeW1y4EDBVlN25m4OOcYODSZ4ly4Vzg05wd7kyu8X0biXYsZHH/KsdY2bc4MdQJfXSvgvikOLO6+ADj6IV7hjeYsFFvUe3n5ZaNGwtjuSn/ourhd1wF7gXsPC+3Xln89ZLh00GpLuh7NaSF5FwzmeND1ZdPipVVyOV8/QhLti4E+iIWAwcs/mzPG3SlmlA7fe11AhCtY9wu5S9WhBOFKTKfoI+OJKwHL1Vcs8wavT9qM5UO6S/VOM=
- Authentication-results: smail; arc=none
- Delivery-date: Sun, 14 Jan 2024 17:36:31 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1705250180; bh=hdGGCLpSWw33+58uDRZO7aa/3hovjEqKLF47Rbv1Tg0=; h=Date:From:To:Subject:From; b=QE0JfU5NABujf2RRTs2Q8jgFKHOdsooBGN/g/rUXDum4K8ZsHijRhOfGXo5T12yqN JR7NXDOG9nmg2MTFcJqIppph4K1NpScJUCgtrQa50MqgmAcpYc8t5eKb8pYtGy8Xo2 v6LxgXPCf2ylxdRsQEtWrHWGja0Rbk4LU13H1UifSdJ3pWNPD6HEdnlIa6hmYbTqg1 lMBRDg3p5LOiB6NNOM9aJ8V1X5hYloQmi2RLOlLs+BprhGMckycf2EUxN5v0/B8Y5F iUep5VB5OG1PBewc7oJYf7klVP+XRnAonEK1d5TRyqRQesNet+I03gt1aDweyYqhiZ nID7UFW2BtgjPyGwW2pXE+4Ei5npVCF65blzwoXmJx0xumWdzz506j7cXSwh+lmlfc FVkD4kyt1sbZB0HrZA2c+jRjP6AEcLB57iuBBP81qNZ1T2N4aV0xq5js78q6iK537e FRMIER/kAVEiTDmodkGDb8MaSNOsXxLvAwwh0NCAG/LhcY53yABsvC9R/Sioi/8X9o q1AYZBwpZTuigK5jcsP9hYZKfysfMwrNtvYDfe2vgK/pgV8a1zXTcC7WWFXUaRUZym /CipblqiogUfGHFM0ha5HpEW9f2ohBaD21ZWfzdR91f42cloiYaRaxpn6BRRLHkTzR XhsLptDUG6VqyRCD3U/YcnjY=
- Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
Dear PARI developers,
I have added a new GP function mapapply:
mapapply(~M,x,f):
Applies the closure f to the image y of x by the map M and returns the evaluation of f. The closure f is eventually allowed to modify
the components of y in place.
To apply f to all entries of M use apply(f, M) instead.
There are two main use cases: * performing a computation on a value without copying it:
? M=Map();mapput(~M,"a",mathilbert(100));
? for(i=1,1000,matsize(mapget(M,"a"))) \\ Slow
? for(i=1,1000,mapapply(M,"a",matsize)) \\ Fast
* modifying the components of the value in place, for example to append an element to a value of a map of lists. This require to use ~
in the function declaration.
? maplistput(~M,k,v) = mapapply(~M,k,(~y)->listput(~y,v));
? M = Map(["a",List(); "b",List()]);
? maplistput(~M,"a",1234); M
%3 = Map(["a",List([1234]);"b",List([])])
Cheers,
Bill