Equivalent to Remove-Dup

Discussions, advice, bug reports and much more about the "bach" environment.
Post Reply
lanematthewc
Posts: 1
Joined: Wed Apr 05, 2017 2:14 pm

Equivalent to Remove-Dup

Post by lanematthewc » Wed Apr 05, 2017 2:20 pm

Hello,

I spent a while working through the library looking for an easy equivalent to the OpenMusic "remove-dup" for removing duplicates from a list. I couldn't find one, so I created a very basic version, but doesn't retain the order or nesting of the original list. I've attached it here, but if anyone has anything more elaborate, I'd love to know. I'm sure nested lists could easily be handled through recursion.
Matthew

Code: Select all

{
	"boxes" : [ 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "p bach.unique",
				"numinlets" : 1,
				"patching_rect" : [ 50.0, 153.0, 86.0, 20.0 ],
				"fontsize" : 12.0,
				"id" : "obj-29",
				"fontname" : "Arial",
				"outlettype" : [ "" ],
				"numoutlets" : 1,
				"patcher" : 				{
					"fileversion" : 1,
					"appversion" : 					{
						"major" : 6,
						"minor" : 1,
						"revision" : 10,
						"architecture" : "x64"
					}
,
					"rect" : [ 0.0, 0.0, 640.0, 480.0 ],
					"bglocked" : 0,
					"openinpresentation" : 0,
					"default_fontsize" : 12.0,
					"default_fontface" : 0,
					"default_fontname" : "Arial",
					"gridonopen" : 0,
					"gridsize" : [ 15.0, 15.0 ],
					"gridsnaponopen" : 0,
					"statusbarvisible" : 2,
					"toolbarvisible" : 1,
					"boxanimatetime" : 200,
					"imprint" : 0,
					"enablehscroll" : 1,
					"enablevscroll" : 1,
					"devicewidth" : 0.0,
					"description" : "",
					"digest" : "",
					"tags" : "",
					"boxes" : [ 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.rev",
								"numinlets" : 1,
								"patching_rect" : [ 198.0, 288.0, 57.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-8",
								"fontname" : "Arial",
								"outlettype" : [ "" ],
								"numoutlets" : 1
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "message",
								"text" : "clear, a",
								"numinlets" : 2,
								"patching_rect" : [ 223.0, 208.0, 49.0, 18.0 ],
								"fontsize" : 12.0,
								"id" : "obj-11",
								"fontname" : "Arial",
								"outlettype" : [ "" ],
								"numoutlets" : 1
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.diff",
								"numinlets" : 3,
								"patching_rect" : [ 198.0, 352.0, 56.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-12",
								"fontname" : "Arial",
								"outlettype" : [ "", "", "" ],
								"numoutlets" : 3
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.slice",
								"numinlets" : 1,
								"patching_rect" : [ 198.0, 320.0, 64.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-13",
								"fontname" : "Arial",
								"outlettype" : [ "", "" ],
								"numoutlets" : 2
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "t s b",
								"numinlets" : 1,
								"patching_rect" : [ 50.0, 100.0, 33.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-14",
								"fontname" : "Arial",
								"outlettype" : [ "", "bang" ],
								"numoutlets" : 2
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.stream 2",
								"numinlets" : 1,
								"patching_rect" : [ 198.0, 250.0, 87.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-15",
								"fontname" : "Arial",
								"outlettype" : [ "" ],
								"numoutlets" : 1
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.sort",
								"numinlets" : 2,
								"patching_rect" : [ 50.0, 176.0, 60.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-16",
								"fontname" : "Arial",
								"outlettype" : [ "", "", "", "" ],
								"numoutlets" : 4
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.mapelem @maxdepth 1",
								"numinlets" : 2,
								"patching_rect" : [ 50.0, 208.0, 167.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-17",
								"fontname" : "Arial",
								"outlettype" : [ "", "" ],
								"numoutlets" : 2
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "newobj",
								"text" : "bach.flat",
								"numinlets" : 1,
								"patching_rect" : [ 50.0, 146.0, 56.0, 20.0 ],
								"fontsize" : 12.0,
								"id" : "obj-20",
								"fontname" : "Arial",
								"outlettype" : [ "" ],
								"numoutlets" : 1
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "inlet",
								"numinlets" : 0,
								"patching_rect" : [ 50.0, 40.0, 25.0, 25.0 ],
								"id" : "obj-27",
								"outlettype" : [ "" ],
								"numoutlets" : 1,
								"comment" : ""
							}

						}
, 						{
							"box" : 							{
								"maxclass" : "outlet",
								"numinlets" : 1,
								"patching_rect" : [ 50.0, 436.5, 25.0, 25.0 ],
								"id" : "obj-28",
								"numoutlets" : 0,
								"comment" : ""
							}

						}
 ],
					"lines" : [ 						{
							"patchline" : 							{
								"source" : [ "obj-13", 1 ],
								"destination" : [ "obj-12", 1 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-13", 0 ],
								"destination" : [ "obj-12", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-11", 0 ],
								"destination" : [ "obj-15", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-8", 0 ],
								"destination" : [ "obj-13", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-17", 1 ],
								"destination" : [ "obj-15", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-15", 0 ],
								"destination" : [ "obj-8", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-16", 0 ],
								"destination" : [ "obj-17", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-20", 0 ],
								"destination" : [ "obj-16", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-12", 0 ],
								"destination" : [ "obj-17", 1 ],
								"hidden" : 0,
								"midpoints" : [ 207.5, 374.0, 341.0, 374.0, 341.0, 182.0, 219.0, 182.0, 219.0, 203.0, 207.5, 203.0 ],
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-14", 1 ],
								"destination" : [ "obj-11", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-14", 0 ],
								"destination" : [ "obj-20", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-27", 0 ],
								"destination" : [ "obj-14", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
, 						{
							"patchline" : 							{
								"source" : [ "obj-17", 0 ],
								"destination" : [ "obj-28", 0 ],
								"hidden" : 0,
								"disabled" : 0
							}

						}
 ]
				}
,
				"saved_object_attributes" : 				{
					"default_fontface" : 0,
					"default_fontname" : "Arial",
					"default_fontsize" : 12.0,
					"description" : "",
					"digest" : "",
					"fontface" : 0,
					"fontname" : "Arial",
					"fontsize" : 12.0,
					"globalpatchername" : "",
					"tags" : ""
				}

			}

		}
 ],
	"appversion" : 	{
		"major" : 6,
		"minor" : 1,
		"revision" : 10,
		"architecture" : "x64"
	}

}


danieleghisi
Site Admin
Posts: 1349
Joined: Fri Dec 03, 2010 1:25 pm

Re: Equivalent to Remove-Dup

Post by danieleghisi » Wed Apr 05, 2017 4:20 pm

Hi, you have bach.thin that does exactly that job.
As a more general tip, if you go in the Explorer (in bach overview), you have a list of all the llll modules.

Post Reply